diff --git a/YACOSWeb/WebContent/WEB-INF/classes/messages.properties b/YACOSWeb/WebContent/WEB-INF/classes/messages.properties index cb740e8..d88d4af 100644 --- a/YACOSWeb/WebContent/WEB-INF/classes/messages.properties +++ b/YACOSWeb/WebContent/WEB-INF/classes/messages.properties @@ -19,11 +19,12 @@ login.label.login=Login login.label.password=Password login.label.rememberme=Remember me login.label.register=Register -login.label.alreadyaccount:I have already an account +login.label.alreadyaccount:I already have an account # New user login.label.createnewuser=Create an account login.label.createaccount="When creating an account on Yacos.com, you may post an article and follow the conference." login.label.continue=Continue +login.label.forgotPasswordHeading=Forgot your password ? login.message.error=Your login attempt was not successful, try again. ################### @@ -87,6 +88,15 @@ form.register.error.passwordEmpty=The password can't be empty form.register.error.alreadyExists=A user with this login already exists. Please check you haven't already registered or change your login. +################### +# FORGOT USER +form.forgotPassword.error.emailInvalid=This email is invalid +form.forgotPassword.error.unknownEmail=This email is not registered in our system +form.forgotPassword.email=E-Mail address for your account : +form.forgotPassword.submit=Request new password +form.forgotPassword.help=Please enter the email address you used for your YACOS account.\nA new password will be generated and sent into your mailbox. +forgotPassword.title=Reset your password + ################### # MESSAGE ERROR message.error.noconferenceforthisid=This conference doesn't exist. Pease try again diff --git a/YACOSWeb/WebContent/WEB-INF/decorators/main.jsp b/YACOSWeb/WebContent/WEB-INF/decorators/main.jsp index b2710ab..2ec73dd 100644 --- a/YACOSWeb/WebContent/WEB-INF/decorators/main.jsp +++ b/YACOSWeb/WebContent/WEB-INF/decorators/main.jsp @@ -11,6 +11,7 @@ <fmt:message key="title" /> + diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/forgotPassword.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/forgotPassword.jsp new file mode 100644 index 0000000..4aafbbf --- /dev/null +++ b/YACOSWeb/WebContent/WEB-INF/jsp/forgotPassword.jsp @@ -0,0 +1,28 @@ +<%@ include file="/WEB-INF/decorators/include.jsp"%> + + + + + + +

+

+ +

+
+ +

+ + + +

+ +
+ +
+ "/> +
+
+ + + \ No newline at end of file diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp index 1768c54..ce14890 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/listArticle.jsp @@ -5,22 +5,23 @@

NO NAME

- + +

Topic: ${article.topic}

+

+ + ">Download the article +

+


diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/listConference.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/listConference.jsp index 47b9549..87545dc 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/listConference.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/listConference.jsp @@ -32,7 +32,8 @@ -
+
+

${conference.title}

ID : ${conference.id}
Title : ${conference.title}
Description : ${conference.description}
diff --git a/YACOSWeb/WebContent/WEB-INF/jsp/loginFull.jsp b/YACOSWeb/WebContent/WEB-INF/jsp/loginFull.jsp index a3dc53b..a4cf1f8 100644 --- a/YACOSWeb/WebContent/WEB-INF/jsp/loginFull.jsp +++ b/YACOSWeb/WebContent/WEB-INF/jsp/loginFull.jsp @@ -15,11 +15,14 @@
-
+
+


- + +
- :
+
+

:

:
:
@@ -28,7 +31,12 @@

- +
+ "> + + +
+
diff --git a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml index 7ca5419..c3c66e1 100644 --- a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml +++ b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml @@ -75,8 +75,10 @@ ListReportController + + + ForgotPasswordController - @@ -117,6 +119,17 @@ + + + + + + + + + * { + display: list-item; + list-style-position: inside; + list-style-image: url(../images/error_bullet.png); } /* @group Login */ @@ -138,7 +155,6 @@ body { } #maincontent { - position: relative; color: #333; } @@ -212,13 +228,17 @@ body { padding-right: 10px; } +#maincontent > * { + margin-right: 10px; +} + #main #maincontent h4.title { color: #fff; font-weight: bold; height: 23px; - position: relative; top: 2px; margin-bottom: 6px; + margin-left: 0; } /* @end */ @@ -298,4 +318,109 @@ body { .selected { background-color: #fea752; } + +/* @end */ + +/* @group general purpose */ + +.centered { + margin: auto; +} + +/* @end */ + +/* @group rounded box */ + +.cb h2 { + margin-left: -11px; + margin-right: -11px; + padding-left: 10px; + padding-right: 10px; + border-color: #fd7738; + margin-bottom: 10px; + font-weight: bolder; + border-bottom: 2px solid #df9b7b; +} + +/* Normal styling */ +.cb { + margin:0.5em 0; +} + /* Top corners and border */ +.bt { + height:19px; + margin:0 0 0 19px; + background:url(../images/box.png) no-repeat 100% 0; +} +.bt div { + position:relative; + left:-19px; + width:19px; + height:19px; + background:url(../images/box.png) no-repeat 0 0; + font-size:0; + line-height:0; +} + + /* Bottom corners and border */ +.bb { + height:19px; + margin:0 0 0 19px; + background:url(../images/box.png) no-repeat 100% 100%; +} +.bb div { + position:relative; + left:-19px; + width:19px; + height:19px; + background:url(../images/box.png) no-repeat 0 100%; + font-size:0; + line-height:0; +} + + /* Left border */ +.i1 { + padding:0 0 0 11px; + background:url(../images/borders.png) repeat-y 0 0; +} + /* Right border */ +.i2 { + padding:0 11px 0 0; + background:url(../images/borders.png) repeat-y 100% 0; +} + /* Wrapper for the content. Use it to set the background colour and insert some padding between the borders and the content. */ +.i3 { + display:block; + margin:0; + padding:1px 10px; + background:#fff; +} + /* Make the content wrapper auto clearing so it will contain floats (see http://positioniseverything.net/easyclearing.html). */ +.i3:after { + content:"."; + display:block; + height:0; + clear:both; + visibility:hidden; +} +.i3 {display:inline-block;} +.i3 {display:block;} +/* Default CSS ends here */ + +/* @end */ + +/* @group yacos_button */ + +.yacos_button { + display: inline-block; + background-image: url(../images/button_background_idle.png); + max-height: 40px; + min-width: 50px; + padding:10px; +} + +.yacos_button:hover { + background-image: url(../images/button_background_hover.png); +} + /* @end */ \ No newline at end of file diff --git a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java index e341ada..dff9d1a 100644 --- a/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java +++ b/YACOSWeb/src/org/yacos/web/author/controller/SArticleController.java @@ -54,19 +54,6 @@ public class SArticleController extends SimpleFormController { String nomFile=""; - Article newArticle = articleManager.addArticle( - title, theme, nomFile, user.getLogin(), - listSecondaryAuthor, Article.State.SUBMITED, conf.getId()); - - if(newArticle==null){ - errors.reject("article.errors.didNotSave"); - try { - return showForm(request, response, errors); - } catch (Exception e) { - e.printStackTrace(); - } - } - try { MultipartFile file = ((FormSubmission) command).getFile(); if (file == null || file.isEmpty()) { @@ -78,7 +65,21 @@ public class SArticleController extends SimpleFormController { } } else { - + + // Creates the article + Article newArticle = articleManager.addArticle( + title, theme, nomFile, user.getLogin(), + listSecondaryAuthor, Article.State.SUBMITED, conf.getId()); + + if(newArticle==null){ + errors.reject("article.errors.didNotSave"); + try { + return showForm(request, response, errors); + } catch (Exception e) { + e.printStackTrace(); + } + } + byte b[] = file.getBytes(); String path = "conference"+conf.getId()+"/"; diff --git a/YACOSWeb/src/org/yacos/web/system/controller/ForgotPasswordController.java b/YACOSWeb/src/org/yacos/web/system/controller/ForgotPasswordController.java new file mode 100644 index 0000000..b8ab02a --- /dev/null +++ b/YACOSWeb/src/org/yacos/web/system/controller/ForgotPasswordController.java @@ -0,0 +1,68 @@ +package org.yacos.web.system.controller; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.springframework.validation.BindException; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.SimpleFormController; +import org.yacos.core.users.IUserManager; +import org.yacos.core.users.User; +import org.yacos.web.system.form.FormForgotPassword; +import org.yacos.web.system.session.YACOSUtils; + +public class ForgotPasswordController extends SimpleFormController { + private IUserManager userManager; + + @Override + protected ModelAndView onSubmit(HttpServletRequest request, + HttpServletResponse response, Object command, BindException errors) + throws Exception { + String email = ((FormForgotPassword) command).getEmail(); + + email = email.toLowerCase(); + Pattern emailPattern = Pattern.compile("^[a-z0-9._-]+@[a-z0-9._-]{2,}[.][a-z]{2,4}$"); // Regex + Matcher emailMatcher = emailPattern.matcher(email); + + User user = null; + if(!emailMatcher.matches()){ + errors.rejectValue("email", "form.forgotPassword.error.emailInvalid"); + } else { + + user = userManager.getUserByEmail(email); + if(user == null){ + errors.rejectValue("email", "form.forgotPassword.error.unknownEmail"); + } + } + + if(errors.hasErrors()){ + return showForm(request,response, errors); + } else { + String newPassword = YACOSUtils.generate(12); + user.setPassword(User.hashPassword(newPassword)); + + System.out.println(newPassword); + + userManager.UpdateUser(user); + + String mailSubject = "Your new YACOS password"; + String mailBody = "You received this email because you requested your account informations.\n"; + mailBody += "A new password has been generated, you can now login using the following informations and change it in your profile view.\n"; + mailBody += "User login : "+user.getLogin()+"\n"; + mailBody += "User password : "+newPassword; + + MailSenderService.getInstance().sendEMail(email, mailSubject, mailBody); + + return new ModelAndView(getSuccessView()); + } + } + + public void setUserManager(IUserManager userManager) { + this.userManager = userManager; + } + + public IUserManager getUserManager() { + return userManager; + } +} diff --git a/YACOSWeb/src/org/yacos/web/system/controller/SUserRegistrationController.java b/YACOSWeb/src/org/yacos/web/system/controller/SUserRegistrationController.java index 7bfc166..20ffc28 100644 --- a/YACOSWeb/src/org/yacos/web/system/controller/SUserRegistrationController.java +++ b/YACOSWeb/src/org/yacos/web/system/controller/SUserRegistrationController.java @@ -5,7 +5,6 @@ package org.yacos.web.system.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.SimpleFormController; @@ -85,7 +84,7 @@ public class SUserRegistrationController extends SimpleFormController { // We try to see if the user is already registered and logged User currentUser = new User(); user.setIsNew(true); - // TODO : see how JAAS could change the way of getting the current User + if(SessionService.getInstance().isUserLogged()){ // If he is logged, we use his profile information to fill the form currentUser = (User) SessionService.getInstance().getCurrentUser(); diff --git a/YACOSWeb/src/org/yacos/web/system/form/FormForgotPassword.java b/YACOSWeb/src/org/yacos/web/system/form/FormForgotPassword.java new file mode 100644 index 0000000..9905aaf --- /dev/null +++ b/YACOSWeb/src/org/yacos/web/system/form/FormForgotPassword.java @@ -0,0 +1,13 @@ +package org.yacos.web.system.form; + +public class FormForgotPassword { + private String email; + + public void setEmail(String email) { + this.email = email; + } + + public String getEmail() { + return email; + } +} diff --git a/YACOSWeb/src/org/yacos/web/system/session/YACOSUtils.java b/YACOSWeb/src/org/yacos/web/system/session/YACOSUtils.java new file mode 100644 index 0000000..cf2d8a5 --- /dev/null +++ b/YACOSWeb/src/org/yacos/web/system/session/YACOSUtils.java @@ -0,0 +1,15 @@ +package org.yacos.web.system.session; + +public class YACOSUtils { + private static String VALID_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!?%$()"; + + public static String generate(Integer length){ + String password = new String(); + + for(int i=0;i