Commit d0beffee by Tuukka Kivilahti

asm-muutoksia, userjutukkeita

1 parent 8f72d811
......@@ -425,6 +425,11 @@ public class UserBean implements UserBeanLocal {
user.getUser().resetPassword(password);
user.setEvent(eventBean.getCurrentEvent());
if(user.getLogin() == null || user.getLogin().trim().isEmpty()) {
user.setLogin(user.getEmail());
}
// Tallennetaan olio kantaan...
eventUserFacade.create(user);
......
......@@ -53,9 +53,7 @@
<h:panelGroup>
<table>
<tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> <br /> <p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" /></td>
</tr>
<tr>
<td><h:outputLabel value="#{i18n['user.firstNames']}" for="firstnames" /><br /> <p:inputText size="22" id="firstnames" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.firstnames}" /></td>
<td><h:outputLabel value="#{i18n['user.lastName']}" for="lastname" /><br /> <p:inputText size="30" id="lastname" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.lastname}" /></td>
......@@ -70,45 +68,68 @@
</tr>
</table>
<table>
<table >
<tr>
<td colspan="2">
<p:outputLabel value="#{i18n['user.address']}" for="address" /><br />
<p:inputTextarea rows="2" cols="45" id="address" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.address}" />
</td>
</tr>
<tr>
<td>
<p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /><br />
<p:inputText styleClass="ui-input" size="7" id="zip" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.zip}" /> <p:message for="zip" />
</td>
<td>
<p:outputLabel value="#{i18n['user.town']}" for="town" /><br />
<p:inputText styleClass="ui-input" size="25" id="town" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.town}" />
<p:message for="town" />
</td>
</tr>
<tr>
<td colspan="2"><p:outputLabel value="#{i18n['user.address']}" for="address" /><br /> <p:inputText size="45" id="address" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.address}" /></td>
<td colspan="2">
<p:outputLabel value="* #{i18n['user.emailAndUsername']}" for="email" />
<br />
<p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" required="true" requiredMessage="#{i18n['required']}" />
<p:message for="email" />
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td><p:outputLabel value="#{i18n['user.zipCode']}" for="zip" /><br /> <p:inputText styleClass="ui-input" size="7" id="zip" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.zip}" /> <p:message for="zip" /></td>
<td><p:outputLabel value="#{i18n['user.town']}" for="town" /><br /> <p:inputText styleClass="ui-input" size="25" id="town" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.town}" /> <p:message for="town" /></td>
<td colspan="2">
<p:outputLabel value="#{i18n['user.emailAgain']}" for="email2" />
<br />
<p:inputText validator="#{userValidator.validateEmail}" size="45" id="email2" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.emailCheck}" required="true" requiredMessage="#{i18n['required']}" />
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td colspan="2"><h:outputLabel value="#{i18n['user.email']}" for="email" /> <br /> <p:inputText validator="#{userValidator.validateEmail}" size="45" id="email" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.email}" /></td>
<td colspan="2">
<p:outputLabel value="#{i18n['user.phone']}" for="phone" />
<br />
<p:inputMask size="45" id="phone" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.phone}" mask="+99?9 9999999999999999999" required="true" requiredMessage="#{i18n['required']}" />
<p:message for="phone" />
</td>
</tr>
<tr>
<td><p:outputLabel value="#{i18n['user.phone']}" for="phone" /><br /> <p:inputText size="9" id="phone" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.phone}" /> <p:message for="phone" /></td>
<td colspan="2"><h:outputLabel value="#{i18n['user.nick']}" for="nick" /> <br /> <p:inputText size="45" id="nick" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.nick}" /></td>
</tr>
</table>
<br />
<ui:fragment rendered="#{cc.attrs.creating}">
<h:outputLabel value="#{i18n['user.login']}" for="login" />
<br />
<p:inputText size="25" id="login" validator="#{userValidator.login}" disabled="#{!cc.attrs.creating and !userView.canSave}" value="#{userView.selectedUser.login}" />
<p:message for="login" />
<br />
</ui:fragment>
<br />
<p:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.password']}" for="password" />
<h:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.password']}" for="password" />
<br />
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" />
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" feedback="true" required="true" requiredMessage="#{i18n['required']}" />
<p:message for="password" />
<br />
<p:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}" for="passwordcheck" />
<br />
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" />
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" required="true" requiredMessage="#{i18n['required']}" />
<br />
......
......@@ -41,11 +41,14 @@ import fi.codecrew.moya.utilities.I18n;
public class UserValidator implements Serializable {
private String firstpwd;
private String firstemail;
/**
*
*/
private static final long serialVersionUID = 8081093389856720678L;
private static final Integer PASSWORD_MIN_LENGTH = 8;
private static final Integer EMAIL_MIN_LENGTH = 6; // a@a.fi
@EJB
private transient UserBeanLocal userbean;
@EJB
......@@ -54,11 +57,23 @@ public class UserValidator implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(UserValidator.class);
public void validateEmail(FacesContext context, UIComponent ui, Object value) {
String email = (String) value;
// I think that a@a.fi is shortest form of possible email?
if(email.trim().length() < EMAIL_MIN_LENGTH ) {
message(context, ui, "user.emailtooshortmessage", EMAIL_MIN_LENGTH);
}
if (!permbean.hasPermission(UserPermission.MODIFY) && (email == null || email.indexOf('@') == -1)) {
message(context, ui, "userview.invalidEmail");
}
if(firstemail == null || firstemail.trim().isEmpty()) {
firstemail = email;
} else if(!firstemail.equals(email)) {
message(context, ui, "user.emailsunmatch");
}
}
public void login(FacesContext context, UIComponent ui, Object object) {
......@@ -72,8 +87,9 @@ public class UserValidator implements Serializable {
}
public void password(FacesContext context, UIComponent ui, Object object) {
logger.info("Executing pwd, firstpwd {}", firstpwd);
if (!permbean.hasPermission(UserPermission.MODIFY))
{
......
......@@ -81,6 +81,8 @@ public class UserView extends GenericCDIView {
@EJB
private transient UserBeanLocal userbean;
@EJB
private transient ReaderBeanLocal readerbean;
......@@ -108,6 +110,9 @@ public class UserView extends GenericCDIView {
private boolean canSave = false;
private String username;
private String password;
private String emailCheck;
private String passwordcheck;
@EJB
......@@ -429,6 +434,14 @@ public class UserView extends GenericCDIView {
public String createUser() {
userbean.createNewUser(user, getPassword());
if(!permbean.isLoggedIn()) {
authView.setLogin(user.getLogin());
authView.setPassword(getPassword());
navihandler.saveNavigation("/user/created");
authView.executeLogin();
}
return "/user/created";
}
......@@ -618,4 +631,13 @@ public class UserView extends GenericCDIView {
return "";
}
public String getEmailCheck() {
return emailCheck;
}
public void setEmailCheck(String emailCheck) {
this.emailCheck = emailCheck;
}
}
......@@ -416,3 +416,10 @@ usercart.showoverview = Vie tarkastusn\u00E4kym\u00E4\u00E4n
viewlectures.title = Kurssit ja luennot
yes = Kyll\u00E4
user.emailAndUsername=Email (toimii k\u00E4ytt\u00E4j\u00E4tunnuksena)
user.emailtooshortmessage=
user.emailsunmatch=
user.emailAgain=S\u00E4hk\u00F6posti (uudelleen)
user.email=S\u00E4hk\u00F6postiosoite
required=Arvo vaaditaan
user.createdmessage=K\u00E4ytt\u00E4j\u00E4tunnus on luotu onnistuneesti.
......@@ -1425,7 +1425,7 @@ user.accountBalance = Account balance
user.accountEventHeader = Account events
user.accountevents = Account events
user.addToEvent = Associate user to event
user.address = Address
user.address = Street address
user.age = Age
user.bank = Bank
user.bankaccount = Bank number
......@@ -1436,7 +1436,7 @@ user.changepassword.forUser = For user
user.changepassword.title = Change password
user.confirmUserToEventAdding = Are you sure you want to associate this user to this event?
user.create = Create user
user.createdmessage = User has been created successfully. You can now login.
user.createdmessage = User has been created successfully.
user.cropImage = Crop image
user.cropUserImage = Crop image
user.defaultImage = Default picture
......@@ -1499,7 +1499,7 @@ user.sendPicture = Send image
user.sex = Sex
user.sex.FEMALE = Female
user.sex.MALE = Male
user.sex.UNDEFINED = Undefined
user.sex.UNDEFINED = Prefer not to say
user.shirt.L = Unisex L
user.shirt.LadyL = Ladyfit L
user.shirt.LadyM = Ladyfit M
......@@ -1561,7 +1561,7 @@ userview.header = Users
userview.invalidEmail = Invalid email address
userview.loginstringFaulty = Username has to be atleast 2 characters long!
userview.oldPasswordError = Invalid password!
userview.passwordTooShort = Password has to be atleast 5 characters long!
userview.passwordTooShort = Password has to be atleast {0} characters long\!
userview.passwordsChanged = Password changed
userview.passwordsDontMatch = Passwords do not match! Please try again!
userview.userExists = Username already exists! You may already have an account.
......@@ -1616,3 +1616,8 @@ voting.create.voteStart = Voting start
yes = Yes
shop.unitdiscount=Discount
shop.customPrice=new price
user.emailAndUsername=Email (works also as username)
user.emailtooshortmessage=Email must be atleast {0} characters long.
user.emailsunmatch=Email addresses does not match.
user.emailAgain=Email (again)
required=Required
......@@ -1408,7 +1408,7 @@ user.accountBalance = Tilin saldo
user.accountEventHeader = Tilitapahtumat
user.accountevents = Tilitapahtumat
user.addToEvent = Liit\u00E4 k\u00E4ytt\u00E4j\u00E4 tapahtumaan
user.address = Osoite
user.address = l\u00E4hiosoite
user.age = Ik\u00E4
user.bank = Pankki
user.bankaccount = Pankkitili
......@@ -1419,7 +1419,7 @@ user.changepassword.forUser = K\u00E4ytt\u00E4j\u00E4lle
user.changepassword.title = Vaihda salasana
user.confirmUserToEventAdding = Oletko varma ett\u00E4 haluat liitt\u00E4\u00E4 t\u00E4m\u00E4n k\u00E4ytt\u00E4j\u00E4n t\u00E4h\u00E4n tapahtumaan?
user.create = Luo k\u00E4ytt\u00E4j\u00E4
user.createdmessage = K\u00E4ytt\u00E4j\u00E4tunnus on luotu onnistuneesti. Voit nyt kirjautua sis\u00E4\u00E4n.
user.createdmessage = K\u00E4ytt\u00E4j\u00E4tunnus on luotu onnistuneesti.
user.cropImage = Rajaa
user.cropUserImage = Crop image
user.defaultImage = Oletukuva
......@@ -1482,7 +1482,7 @@ user.sendPicture = Kuvan l\u00E4hetys
user.sex = Sukupuoli
user.sex.FEMALE = Nainen
user.sex.MALE = Mies
user.sex.UNDEFINED = M\u00E4\u00E4rittelem\u00E4tt\u00E4
user.sex.UNDEFINED = En halua kertoa
user.shirt.L = Unisex L
user.shirt.LadyL = Ladyfit L
user.shirt.LadyM = Ladyfit M
......@@ -1598,3 +1598,8 @@ voting.create.voteStart = \u00C4\u00E4nestys auki
yes = Kyll\u00E4
shop.unitdiscount=Alennus
shop.customPrice=Uusi hinta
user.emailAndUsername=S\u00E4hk\u00F6posti (toimii my\u00F6s k\u00E4ytt\u00E4j\u00E4tunnuksena)
user.emailtooshortmessage=S\u00E4hk\u00F6postin tarvitsee olla v\u00E4hint\u00E4\u00E4n {0} merkki\u00E4 pitk\u00E4.
user.emailsunmatch=S\u00E4hk\u00F6postiosoitteet eiv\u00E4t t\u00E4sm\u00E4\u00E4.
user.emailAgain=S\u00E4hk\u00F6posti (uudelleen)
required=Vaaditaan
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!