Commit e2de4678 by Tuomas Riihimäki

Password changing stuff.

1 parent 3c5bba7a
...@@ -366,7 +366,9 @@ public class UserBean implements UserBeanLocal { ...@@ -366,7 +366,9 @@ public class UserBean implements UserBeanLocal {
@Override @Override
public boolean initPasswordResetForEmail(String email, String url) { public boolean initPasswordResetForEmail(String email, String url) {
List<User> users = userFacade.findByEmail(email); List<User> users = userFacade.findByEmail(email);
if (users.size() != 1) { logger.info("Got {} results for email: {}", users.size(), email);
if (users.isEmpty()) {
return false; return false;
} }
return initPasswordReset(users.get(0), url); return initPasswordReset(users.get(0), url);
......
...@@ -18,23 +18,21 @@ ...@@ -18,23 +18,21 @@
</p> </p>
<h:form> <h:form>
<h:outputLabel value="#{i18n['resetMail.username']}:" for="username" />
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="#{i18n['resetMail.username']}:" for="username" />
<h:inputText id="username" value="#{pwdResetView.username}" /> <h:inputText id="username" value="#{pwdResetView.username}" />
<h:message for="username" /> <h:message for="username" />
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendResetUsernameMail()}" />
</h:panelGrid> </h:panelGrid>
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendMail()}" />
</h:form> </h:form>
<h:form> <h:form>
<h:outputLabel value="#{i18n['resetMail.email']}:" for="emailaddr" />
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="#{i18n['resetMail.email']}:" for="emailaddr" />
<h:inputText id="emailaddr" value="#{pwdResetView.emailaddr}" /> <h:inputText id="emailaddr" value="#{pwdResetView.emailaddr}" />
<h:message for="emailaddr" /> <h:message for="emailaddr" />
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendResetEmailMail()}" />
</h:panelGrid> </h:panelGrid>
<h:commandButton id="sendReset" value="#{i18n['resetMail.send']}" action="#{pwdResetView.sendMail()}" />
</h:form> </h:form>
......
...@@ -216,15 +216,13 @@ productshop.minusTen = -10 ...@@ -216,15 +216,13 @@ productshop.minusTen = -10
productshop.plusOne = +1 productshop.plusOne = +1
productshop.plusTen = +10 productshop.plusTen = +10
resetMail.body = You can change a forgotten password by inserting your username to the field below. A link where you can change the password will be sent to the email address associated to that.
resetMail.header = Reset lost password resetMail.header = Reset lost password
resetMail.send = Send email
resetMail.username = Username resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password. resetmailSent.body = Email has been sent containing a link where you can change the password.
resetmailSent.header = Email sent resetmailSent.header = Email sent
submenu.NotImplementedYet = Not implemented submenu.NotImplementedYet = Not implemented
subnavi.cards = \u0009\u0009 subnavi.cards = \u0009\u0009
......
...@@ -627,9 +627,11 @@ passwordChanged.header = Password changed successfully. ...@@ -627,9 +627,11 @@ passwordChanged.header = Password changed successfully.
passwordReset.errorChanging = Unexpected error whilst password reset. Contact your administrator. passwordReset.errorChanging = Unexpected error whilst password reset. Contact your administrator.
passwordReset.hashNotFound = Password change token has expired. Please send the query again. passwordReset.hashNotFound = Password change token has expired. Please send the query again.
passwordreset.mailBody = You can change your password in address: {0}\n\nIf you have not requested password reset, ignore this message.\n\n passwordreset.emailnotfound = Email address not found.
passwordreset.mailSubject = [{0}] Password reset passwordreset.mailBody = You can change your password in address: {0}\n\nIf you have not requested password reset, ignore this message.\n\n
passwordreset.usernotfound = Username not found. Please note that username is case sensitive. passwordreset.mailSubject = [{0}] Password reset
passwordreset.unknownerror = Unknown error when resetting password. Please contact administration
passwordreset.usernotfound = Username not found.
permissiondenied.alreadyLoggedIn = You don't have enough rights permissiondenied.alreadyLoggedIn = You don't have enough rights
permissiondenied.header = Access denied permissiondenied.header = Access denied
...@@ -780,9 +782,10 @@ readerevent.tagname = Tag ...@@ -780,9 +782,10 @@ readerevent.tagname = Tag
readerview.cards = Card ( printcount ) readerview.cards = Card ( printcount )
resetMail.body = You can change a forgotten password by inserting your username to the field below. A link where you can change the password will be sent to the email address associated to that. resetMail.body = You can change a forgotten password by inserting your username or email address to the field below. A link where you can change the password will be sent to the email address associated to that.
resetMail.email = Email address
resetMail.header = Reset lost password resetMail.header = Reset lost password
resetMail.send = Send email resetMail.send = Send
resetMail.username = Username resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password. resetmailSent.body = Email has been sent containing a link where you can change the password.
......
#Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
#Sat Mar 30 17:56:44 EET 2013
actionlog.create.header = Create new actionmessage
actionlog.create.message = Message
actionlog.create.role = Target role
actionlog.create.submitbutton = Send
actionlog.create.taskradio = Task
actionlog.crew = Crew
actionlog.message = Event
actionlog.messagelist.description = You can follow and create new action messages in this view
actionlog.messagelist.header = Messagelist
actionlog.state = State
actionlog.task = Task
actionlog.tasklist.header = Tasklist
actionlog.time = Time
actionlog.user = User
bill.billMarkedPaidMail.message = Your deposit number {0} has been marked as paid.
bill.billMarkedPaidMail.subject = [Streamparty] Your credits have been updated
error.contact = If this happens again, contact Info with the following code:
error.error = You have encountered an error.
eventorg.create = Create
eventorg.edit = Edit
global.cancel = Cancel
global.copyright = Codecrew Ry
global.infomail = info@streamparty.org
global.notAuthorizedExecute = You are not authorized to execute that!!
global.notauthorized = You don't have enough rights to enter this site.
global.save = Save
global.webpage = http://www.streamparty.org
httpsession.creationTime = Created
login.login = Login
login.logout = Logout
login.logoutmessage = You have logged out of the system
login.password = Password
login.submit = Login
login.username = Username
loginerror.header = Login failed
loginerror.message = Username of password incorrect.
loginerror.resetpassword = Reset password
passwordChanged.body = You can now login with the new password.
passwordChanged.header = Password changed successfully.
passwordReset.errorChanging = Unexpected error whilst password reset. Contact your administrator.
passwordReset.hashNotFound = Password change token has expired. Please send the query again.
permissiondenied.alreadyLoggedIn = You don't have enough rights
permissiondenied.header = Access denied
permissiondenied.notLoggedIn = You don't have enough rights to enter this site.
resetMail.body = You can change a forgotten password by inserting your username to the field below. A link where you can change the password will be sent to the email address associated to that.
resetMail.header = Reset lost password
resetMail.send = Send email
resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password.
resetmailSent.header = Email sent
...@@ -609,9 +609,11 @@ passwordChanged.header = Salasana vaihdettu onnistuneesti ...@@ -609,9 +609,11 @@ passwordChanged.header = Salasana vaihdettu onnistuneesti
passwordReset.errorChanging = Odotamaton virhe. Ota yhteytt\u00E4 yll\u00E4pitoon. passwordReset.errorChanging = Odotamaton virhe. Ota yhteytt\u00E4 yll\u00E4pitoon.
passwordReset.hashNotFound = Salasanan vaihto on vanhentunut. Jos haluat vaihtaa salasanan l\u00E4het\u00E4 vaihtopyynt\u00F6 uudelleen. passwordReset.hashNotFound = Salasanan vaihto on vanhentunut. Jos haluat vaihtaa salasanan l\u00E4het\u00E4 vaihtopyynt\u00F6 uudelleen.
passwordreset.mailBody = Voit vaihtaa salasanasi osoitteessa {0}\n\nJos et ole pyyt\u00E4nyt unohtuneen salasanan vaihtamista, ei t\u00E4h\u00E4n viestiin tarvitse reagoida.\n\n passwordreset.emailnotfound = S\u00E4hk\u00F6postiosoitetta ei l\u00F6ydy.
passwordreset.mailSubject = [{0}] Salasanan vaihtaminen passwordreset.mailBody = Voit vaihtaa salasanasi osoitteessa {0}\n\nJos et ole pyyt\u00E4nyt unohtuneen salasanan vaihtamista, ei t\u00E4h\u00E4n viestiin tarvitse reagoida.\n\n
passwordreset.usernotfound = Annettua k\u00E4ytt\u00E4j\u00E4tunnusta ei l\u00F6ydy. Huomioi ett\u00E4 isot ja pienet kirjaimet ovat merkitsevi\u00E4. passwordreset.mailSubject = [{0}] Salasanan vaihtaminen
passwordreset.unknownerror = Tuntematon virhe salasanan palauttamisessa. Ota yhteys yll\u00E4pitoon.
passwordreset.usernotfound = Annettua k\u00E4ytt\u00E4j\u00E4tunnusta ei l\u00F6ydy.
permissiondenied.alreadyLoggedIn = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia! permissiondenied.alreadyLoggedIn = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia!
permissiondenied.header = P\u00E4\u00E4sy kielletty permissiondenied.header = P\u00E4\u00E4sy kielletty
...@@ -765,9 +767,10 @@ readerevent.tagname = Tagi ...@@ -765,9 +767,10 @@ readerevent.tagname = Tagi
readerview.cards = Kortit ( tulostuslkm ) readerview.cards = Kortit ( tulostuslkm )
resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan. resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi tai tunnukseen liitetyn s\u00E4hk\u00F6postiosoitteen allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan.
resetMail.email = S\u00E4hk\u00F6postiosoite
resetMail.header = Salasana unohtunut? resetMail.header = Salasana unohtunut?
resetMail.send = L\u00E4het\u00E4 s\u00E4hk\u00F6posti resetMail.send = L\u00E4het\u00E4
resetMail.username = K\u00E4ytt\u00E4j\u00E4tunnus resetMail.username = K\u00E4ytt\u00E4j\u00E4tunnus
resetmailSent.body = Antamasi k\u00E4ytt\u00E4j\u00E4tunnuksen s\u00E4hk\u00F6postiosoitteeseen on l\u00E4hetetty osoite jossa voit vaihtaa tunnuksen salasanan. resetmailSent.body = Antamasi k\u00E4ytt\u00E4j\u00E4tunnuksen s\u00E4hk\u00F6postiosoitteeseen on l\u00E4hetetty osoite jossa voit vaihtaa tunnuksen salasanan.
......
#Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
#Sat Mar 30 17:56:44 EET 2013
actionlog.create.header = Luo uusi ActionMessage
actionlog.create.message = Viesti
actionlog.create.role = Kohderooli
actionlog.create.submitbutton = L\u00E4het\u00E4
actionlog.create.taskradio = Teht\u00E4v\u00E4
actionlog.crew = Crew
actionlog.message = Tapahtuma
actionlog.messagelist.description = Voit seurata sek\u00E4 luoda uusia ActionMessageja t\u00E4ss\u00E4 n\u00E4kym\u00E4ss\u00E4.
actionlog.messagelist.header = Viestilista
actionlog.state = Tila
actionlog.task = Teht\u00E4v\u00E4
actionlog.tasklist.header = Teht\u00E4v\u00E4lista
actionlog.time = Aika
actionlog.user = Tekij\u00E4
bill.billMarkedPaidMail.message = Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirty\u00E4 lippukauppaan varamaamaan haluamasi paikat. \nTervetuloa tapahtumaan!\n\nTerveisin,\nInsomnia lippupalvelu\nwww.insomnia.fi
bill.billMarkedPaidMail.subject = [INSOMNIA] Lasku merkitty maksetuksi
error.contact = Jos t\u00E4m\u00E4 toistuu, ota seuraava koodi talteen ja ota yhteys Infoon:
error.error = Olet kohdannut virheen.
eventorg.create = Luo
eventorg.edit = Muokkaa
global.cancel = Peruuta
global.copyright = Codecrew Ry
global.infomail = info@insomnia.fi
global.notAuthorizedExecute = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia suorittaa t\u00E4t\u00E4 toimenpidett\u00E4!
global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle sivulle.
global.save = Tallenna
global.webpage = http://www.insomnia.fi
httpsession.creationTime = Luotu
login.login = Kirjaudu sis\u00E4\u00E4n
login.logout = Kirjaudu ulos
login.logoutmessage = Olet kirjautunut ulos j\u00E4rjestelm\u00E4st\u00E4.
login.password = Salasana
login.submit = Kirjaudu sis\u00E4\u00E4n
login.username = K\u00E4ytt\u00E4j\u00E4tunnus
loginerror.header = Kirjautuminen ep\u00E4onnistui
loginerror.message = K\u00E4ytt\u00E4j\u00E4tunnus tai salasana ei ollut oikein.
loginerror.resetpassword = Salasana unohtunut?
passwordChanged.body = Voit nyt kirjautua k\u00E4ytt\u00E4j\u00E4tunnuksella ja uudella salasanalla sis\u00E4\u00E4n j\u00E4rjestelm\u00E4\u00E4n.
passwordChanged.header = Salasana vaihdettu onnistuneesti
passwordReset.errorChanging = Odotamaton virhe. Ota yhteytt\u00E4 yll\u00E4pitoon.
passwordReset.hashNotFound = Salasanan vaihto on vanhentunut. Jos haluat vaihtaa salasanan l\u00E4het\u00E4 vaihtopyynt\u00F6 uudelleen.
permissiondenied.alreadyLoggedIn = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia!
permissiondenied.header = P\u00E4\u00E4sy kielletty
permissiondenied.notLoggedIn = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia t\u00E4lle sivulle.
resetMail.body = Voit vaihtaa unohtuneen salasanan sy\u00F6tt\u00E4m\u00E4ll\u00E4 k\u00E4ytt\u00E4j\u00E4tunnuksesi allaolevaan kentt\u00E4\u00E4n. Tunnukseen liitettyyn s\u00E4hk\u00F6postiosoitteeseen l\u00E4hetet\u00E4\u00E4n kertak\u00E4ytt\u00F6inen osoite jossa voit vaihtaa sy\u00F6tt\u00E4m\u00E4si k\u00E4ytt\u00E4j\u00E4tunnuksen salasanan.
resetMail.header = Salasana unohtunut?
resetMail.send = L\u00E4het\u00E4 s\u00E4hk\u00F6posti
resetmailSent.body = Antamasi k\u00E4ytt\u00E4j\u00E4tunnuksen s\u00E4hk\u00F6postiosoitteeseen on l\u00E4hetetty osoite jossa voit vaihtaa tunnuksen salasanan.
resetmailSent.header = S\u00E4hk\u00F6posti l\u00E4hetetty
page.bill.edit.pagegroup=rai
page.bill.billSummary.pagegroup=asdasd
page.bill.placemap.pagegroup=
page.bill.listAll.pagegroup=
page.permissionDenied.pagegroup=
#Default Category
page.permissionDenied.pagegroup=frontpage
page.bill.placemap.pagegroup=placemap
page.bill.listAll.pagegroup=shop
page.bill.edit.pagegroup=shop
page.bill.billSummary.pagegroup=shop
...@@ -56,7 +56,8 @@ public class PasswordResetView extends GenericCDIView { ...@@ -56,7 +56,8 @@ public class PasswordResetView extends GenericCDIView {
return ret; return ret;
} }
public String sendMail() { private String buildResetAddress()
{
ExternalContext extcontext = FacesContext.getCurrentInstance().getExternalContext(); ExternalContext extcontext = FacesContext.getCurrentInstance().getExternalContext();
StringBuilder path = new StringBuilder(); StringBuilder path = new StringBuilder();
...@@ -76,21 +77,33 @@ public class PasswordResetView extends GenericCDIView { ...@@ -76,21 +77,33 @@ public class PasswordResetView extends GenericCDIView {
path.append("/") path.append("/")
.append(FacesContext.getCurrentInstance().getExternalContext().getContextName()) .append(FacesContext.getCurrentInstance().getExternalContext().getContextName())
.append("/auth/resetPassword.jsf?id={0}&hash={1}"); .append("/auth/resetPassword.jsf?id={0}&hash={1}");
return path.toString();
}
if (username != null && !username.isEmpty()) public String sendResetEmailMail()
{ {
if (userbean.initPasswordResetForUsername(username, path.toString())) { if (getEmailaddr() != null && !getEmailaddr().isEmpty()) {
if (userbean.initPasswordResetForEmail(getEmailaddr(), buildResetAddress())) {
return "/auth/resetmailSent"; return "/auth/resetmailSent";
} }
} else if (emailaddr != null && !emailaddr.isEmpty()) { }
if (userbean.initPasswordResetForUsername(emailaddr, path.toString())) { this.addFaceMessage("passwordreset.emailnotfound");
setUsername(null);
setEmailaddr(null);
return null;
}
public String sendResetUsernameMail() {
if (getUsername() != null && !getUsername().isEmpty()) {
if (userbean.initPasswordResetForUsername(getUsername(), buildResetAddress())) {
return "/auth/resetmailSent"; return "/auth/resetmailSent";
} }
} }
username = null;
emailaddr = null;
this.addFaceMessage("passwordreset.usernotfound"); this.addFaceMessage("passwordreset.usernotfound");
setUsername(null);
setEmailaddr(null);
return null; return null;
} }
...@@ -134,14 +147,6 @@ public class PasswordResetView extends GenericCDIView { ...@@ -134,14 +147,6 @@ public class PasswordResetView extends GenericCDIView {
this.user = user; this.user = user;
} }
public String getMailuser() {
return mailuser;
}
public void setMailuser(String mailuser) {
this.mailuser = mailuser;
}
public UserBeanLocal getUserbean() { public UserBeanLocal getUserbean() {
return userbean; return userbean;
} }
...@@ -150,4 +155,20 @@ public class PasswordResetView extends GenericCDIView { ...@@ -150,4 +155,20 @@ public class PasswordResetView extends GenericCDIView {
this.userbean = userbean; this.userbean = userbean;
} }
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmailaddr() {
return emailaddr;
}
public void setEmailaddr(String emailaddr) {
this.emailaddr = emailaddr;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!