Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c82cc14c
authored
Oct 25, 2014
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'insomnia_2014' of gitlab.codecrew.fi:codecrew/moya into insomnia_2014
2 parents
cc5a533b
bff63de0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
25 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/BootstrapBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
code/moya-web/WebContent/foodmanager/listOrders.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/InviteAcceptView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/BootstrapBeanLocal.java
View file @
c82cc14
...
...
@@ -23,5 +23,6 @@ import javax.ejb.Local;
@Local
public
interface
BootstrapBeanLocal
{
void
saneDefaults
();
// no empty databases
// void saneDefaults();
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
c82cc14
...
...
@@ -298,16 +298,16 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbModelFacade
.
create
(
dBm
);
}
}
public
void
saneDefaults
()
{
User
adminUser
=
userFacade
.
findByLogin
(
"admin"
);
if
(
adminUser
==
null
)
{
adminUser
=
new
User
();
adminUser
.
setLogin
(
"admin"
);
// adminUser.setSuperadmin(true);
adminUser
.
resetPassword
(
"admin"
);
userFacade
.
create
(
adminUser
);
}
}
// We will never run this again with empty database
//
public void saneDefaults() {
//
User adminUser = userFacade.findByLogin("admin");
//
if (adminUser == null) {
//
adminUser = new User();
//
adminUser.setLogin("admin");
//
// adminUser.setSuperadmin(true);
//
adminUser.resetPassword("admin");
//
userFacade.create(adminUser);
//
}
//
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
View file @
c82cc14
...
...
@@ -84,19 +84,23 @@ public class JaasBean implements MoyaRealmBeanRemote {
private
EventBean
eventorgbean
;
public
EventUser
tryLogin
(
String
username
,
String
password
)
{
// username = username.trim().toLowerCase();
EventUser
eventUser
=
eventUserFacade
.
findByLogin
(
username
.
trim
().
toLowerCase
());
EventUser
eventUser
=
eventUserFacade
.
findByLogin
(
username
);
logger
.
info
(
"Found eventuser '{}' with username '{}'"
,
eventUser
,
username
);
User
user
=
null
;
// Might not have EventUser
if
(
eventUser
==
null
)
{
user
=
userfacade
.
findByLogin
(
username
.
trim
()
);
user
=
userfacade
.
findByLogin
(
username
);
}
else
{
user
=
eventUser
.
getUser
();
}
logger
.
info
(
"User '{}' with '{}' "
,
user
,
username
);
// If there is no eventuser found, try to create one.
if
(
user
!=
null
)
{
logger
.
info
(
"TryLogin user not null: {}"
,
user
);
if
(
user
.
isAnonymous
())
{
logger
.
info
(
"logging in as anonymous!!!"
);
}
else
if
(!
user
.
checkPassword
(
password
))
{
...
...
@@ -255,7 +259,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
public
String
authenticateApp
(
String
pathInfo
,
String
appId
,
String
userId
,
String
appStamp
,
String
mac
)
{
logger
.
info
(
"Authenticat app with pathinfo {}, appid {}, userid {}, appstamp {}, mac {}"
,
new
Object
[]
{
pathInfo
,
appId
,
userId
,
appStamp
,
mac
}
new
Object
[]
{
pathInfo
,
appId
,
userId
,
appStamp
,
mac
}
);
if
(
mac
==
null
)
{
logger
.
warn
(
"Rest auth failed: Mac is null"
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
View file @
c82cc14
...
...
@@ -89,11 +89,11 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
*
* @param login
*/
public
User
findByLogin
(
String
login
)
{
public
User
findByLogin
(
final
String
login
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
User
>
cq
=
cb
.
createQuery
(
User
.
class
);
Root
<
User
>
root
=
cq
.
from
(
User
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
User_
.
login
),
login
.
toLowerCase
().
trim
()
));
cq
.
where
(
cb
.
equal
(
root
.
get
(
User_
.
login
),
login
));
return
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
...
...
code/moya-web/WebContent/foodmanager/listOrders.xhtml
View file @
c82cc14
...
...
@@ -80,7 +80,7 @@
<h:outputLabel
value=
"#{i18n['billLine.time']}"
/>
</f:facet>
<h:outputText
value=
"#{bill.sentDate.getTime()}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</p:column>
<p:column
sortBy=
"#{bill.totalQuantity}"
>
...
...
@@ -168,13 +168,13 @@
<h:outputLabel
value=
"#{i18n['foodwave.ordersBefore']}: "
/>
<h:outputText
value=
"#{foodWaveView.selectedFoodWave.time}"
style=
"font-weight: bold"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
<h:outputLabel
value=
"#{i18n['foodwave.foodwaveLastBillPayTime']}: "
/>
<h:outputText
value=
"#{foodWaveView.selectedFoodWave.lastPaymentTime}"
style=
"font-weight: bold"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</p:panelGrid>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/shop/InviteAcceptView.java
View file @
c82cc14
...
...
@@ -115,7 +115,7 @@ public class InviteAcceptView extends GenericCDIView {
if
(
existingUsername
==
null
)
{
try
{
req
.
login
(
usr
,
pwd
);
req
.
login
(
usr
.
trim
().
toLowerCase
()
,
pwd
);
}
catch
(
ServletException
e
)
{
logger
.
warn
(
"Login failed for invite user "
+
usr
,
e
);
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
View file @
c82cc14
...
...
@@ -131,7 +131,7 @@ public class AuthView extends GenericCDIView {
private
void
doLogin
(
String
onError
)
{
bootStrapBean
.
saneDefaults
();
//
bootStrapBean.saneDefaults();
if
(
login
==
null
||
password
==
null
||
login
.
isEmpty
()
||
password
.
isEmpty
())
{
return
;
...
...
@@ -150,7 +150,7 @@ public class AuthView extends GenericCDIView {
}
try
{
request
.
login
(
login
.
toLowerCase
(),
password
);
request
.
login
(
login
.
t
rim
().
t
oLowerCase
(),
password
);
}
catch
(
Throwable
e
)
{
logger
.
info
(
"Error while trying to login {}"
,
e
.
getMessage
());
...
...
@@ -163,7 +163,9 @@ public class AuthView extends GenericCDIView {
}
else
{
navihandler
.
forward
(
onError
);
try
{
request
.
login
(
User
.
ANONYMOUS_LOGINNAME
,
null
);
request
.
logout
();
request
.
getSession
().
invalidate
();
navihandler
.
forward
(
"/frontpage?faces-redirect=true"
);
}
catch
(
ServletException
e
)
{
logger
.
warn
(
"Error while trying to relogin as anonymous"
,
e
);
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment