bug submit form user registration

bug cache password
jstl fn: ajoute
mise en forme user registration + message ok/maj
retablissement de l'ancien acegicontext.xml
This commit is contained in:
Nicolas Michard
2008-02-16 21:02:38 +00:00
parent 04fc7f9523
commit 07052e97c2
11 changed files with 220 additions and 59 deletions

View File

@@ -81,7 +81,12 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<!-- </property>--> <!-- </property>-->
</bean> </bean>
<bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased">
<!-- AUTHORIZATION SERVICES -->
<bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager">
<bean class="org.acegisecurity.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions" value="false"/> <property name="allowIfAllAbstainDecisions" value="false"/>
<property name="decisionVoters"> <property name="decisionVoters">
<list> <list>
@@ -90,11 +95,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
</list> </list>
</property> </property>
</bean> </bean>
</property>
<!-- AUTHORIZATION SERVICES -->
<bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="accessDecisionManager"/>
<property name="objectDefinitionSource"> <property name="objectDefinitionSource">
<value> <value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
@@ -106,18 +107,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
</property> </property>
</bean> </bean>
<bean id="SecurityAnnotationAttributes" class="org.acegisecurity.annotation.SecurityAnnotationAttributes"/>
<bean id="MethodDefinitionAttributes" class="org.acegisecurity.intercept.method.MethodDefinitionAttributes">
<property name="attributes"><ref local="SecurityAnnotationAttributes"/></property>
</bean>
<bean id="methodInvocationInterceptor" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
<property name="validateConfigAttributes"><value>true</value></property>
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="accessDecisionManager"/>
<property name="objectDefinitionSource" ref="MethodDefinitionAttributes"/>
</bean>
<!-- LOGOUT --> <!-- LOGOUT -->
<bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter"> <bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter">
<constructor-arg value="/index.jsp"/> <constructor-arg value="/index.jsp"/>

View File

@@ -86,7 +86,15 @@ form.register.error.firstNameEmpty=First name is required
form.register.error.lastNameEmpty=Last name is required form.register.error.lastNameEmpty=Last name is required
form.register.error.passwordEmpty=The password can't be empty 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. form.register.error.alreadyExists=A user with this login already exists. Please check you haven't already registered or change your login.
form.link.back=Back
form.label.newaccount=You want post an article and participate at one conference ? so create your account !
form.label.message=NOTE: you have already an account ? Please connect you to the
form.label.linkPage=opening session page
form.field.account=Your account
form.field.personal=Personal details
form.field.necessary=* Required informations
message.account.validate=Account created successfully. You can now connect at this.
message.account.maj=Your account was indeed updated.
################### ###################
# FORGOT USER # FORGOT USER

View File

@@ -3,3 +3,4 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="authz" uri="http://acegisecurity.org/authz" %> <%@ taglib prefix="authz" uri="http://acegisecurity.org/authz" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

View File

@@ -6,6 +6,15 @@
<h4 class="title">Conference's list</h4> <h4 class="title">Conference's list</h4>
<c:if test="${ac != null}">
<p class="formHelp">
<c:choose>
<c:when test="${ac == 2}"><fmt:message key="message.account.validate" /></c:when>
<c:when test="${ac == 1}"><fmt:message key="message.account.maj" /></c:when>
</c:choose>
</p>
</c:if>
<c:if test="${errorMessage != null}"> <c:if test="${errorMessage != null}">
<div class="errorBox"> <div class="errorBox">
<c:choose> <c:choose>
@@ -41,7 +50,9 @@
${conference.title} - In this conference you are: ${conference.title} - In this conference you are:
<c:forEach items="${listRole}" var="role"> <c:forEach items="${listRole}" var="role">
<c:if test="${conference.id == role.conference.id}"> <c:if test="${conference.id == role.conference.id}">
${role.type}
${fn:toLowerCase(role.type)}
</c:if> </c:if>
</c:forEach> </c:forEach>
</c:when> </c:when>

View File

@@ -5,33 +5,76 @@
<body> <body>
<h4 class="title"><fmt:message key="register.title" /></h4> <h4 class="title"><fmt:message key="register.title" /></h4>
<form:form method="post" commandName="registerUser">
<div class="user_new">
<fmt:message key="form.label.newaccount" />
</div>
<fmt:message key="form.label.message" />
<a href="<c:url value="login.htm"/>" /><fmt:message key="form.label.linkPage" /></a>
<br />
<form:form method="post" commandName="registerUser" id="account_data">
<form:hidden path="isNew"/> <form:hidden path="isNew"/>
<authz:authorize ifAllGranted="ROLE_ANONYMOUS"> <p class="legend"><fmt:message key="form.field.account" /></p>
<form:label path="login"><fmt:message key="form.register.user.login" /></form:label> <form:input path="login" disabled="false" /> <span class="formError"><form:errors path="login" /></span><br/><br /> <fieldset>
</authz:authorize> <span class="info"><fmt:message key="form.field.necessary" /></span>
<div>
<form:label path="login"><fmt:message key="form.register.user.login" /></form:label>
<authz:authorize ifNotGranted="ROLE_ANONYMOUS"> <authz:authorize ifNotGranted="ROLE_ANONYMOUS">
<form:label path="login"><fmt:message key="form.register.user.login" /></form:label> <form:input path="login" disabled="true"/> <span class="formError"><form:errors path="login" /></span><br/><br /> <form:input path="login" disabled="true"/>*
</authz:authorize> </authz:authorize>
<authz:authorize ifAllGranted="ROLE_ANONYMOUS">
<form:input path="login" disabled="false"/>*
</authz:authorize>
<span class="formError"><form:errors path="login" /></span>
</div>
<div>
<form:label path="password"><fmt:message key="form.register.user.password" /></form:label>
<form:password path="password" showPassword="true"/>*
<span class="formError"><form:errors path="password" /></span>
</div>
<div>
<form:label path="passwordConfirm"><fmt:message key="form.register.user.passwordConfirm" /></form:label>
<form:password path="passwordConfirm" showPassword="true"/>*
</div>
</fieldset>
<form:label path="email"><fmt:message key="form.register.user.email" /></form:label> <form:input path="email"/> <span class="formError"><form:errors path="email" /></span><br/><br /> <p class="legend"><fmt:message key="form.field.personal" /></p>
<form:label path="password"><fmt:message key="form.register.user.password" /></form:label> <form:password path="password" showPassword="true"/> <span class="formError"><form:errors path="password" /></span><br/><br />
<form:label path="passwordConfirm"><fmt:message key="form.register.user.passwordConfirm" /></form:label> <form:password path="passwordConfirm" showPassword="true"/><br/><br />
<form:label path="firstName"><fmt:message key="form.register.user.firstName" /></form:label> <form:input path="firstName"/> <span class="formError"><form:errors path="firstName" /></span><br/><br /> <fieldset>
<form:label path="lastName"><fmt:message key="form.register.user.lastName" /></form:label> <form:input path="lastName"/> <span class="formError"><form:errors path="lastName" /></span><br/><br /> <div>
<form:label path="organization"><fmt:message key="form.register.user.organization" /></form:label> <form:input path="organization"/> <span class="formError"><form:errors path="organization" /></span><br/><br /> <form:label path="firstName"><fmt:message key="form.register.user.firstName" /></form:label>
<form:input path="firstName"/>*
<span class="formError"><form:errors path="firstName" /></span>
</div>
<div>
<form:label path="lastName"><fmt:message key="form.register.user.lastName" /></form:label>
<form:input path="lastName"/>*
<span class="formError"><form:errors path="lastName" /></span>
</div>
<div>
<form:label path="email"><fmt:message key="form.register.user.email" /></form:label>
<form:input path="email"/>*
<span class="formError"><form:errors path="email" /></span>
</div>
<div>
<form:label path="organization"><fmt:message key="form.register.user.organization" /></form:label>
<form:input path="organization"/>
<span class="formError"><form:errors path="organization" /></span>
</div>
</fieldset>
<center>
<a class="back_link" href="<c:url value="login.htm"/>">
<fmt:message key="form.link.back" />
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="register_link" href="javascript:document.getElementById('account_data').submit();">
<fmt:message key="login.label.continue" />
</a>
<input type="reset" value="<fmt:message key="button.reset" />"/> </center>
<input type="submit" value="<fmt:message key="button.OK" />"/> <br/><br/>
</form:form> </form:form>
<a href="<c:url value="main.htm"/>">Home</a>
</body> </body>
</html> </html>

View File

@@ -76,7 +76,6 @@
<property name="commandClass" <property name="commandClass"
value="org.yacos.web.system.form.FormUser" /> value="org.yacos.web.system.form.FormUser" />
<property name="formView" value="registerUser" /> <property name="formView" value="registerUser" />
<property name="successView" value="listConference.htm" />
<property name="userManager" ref="userManager" /> <property name="userManager" ref="userManager" />
<property name="validator" ref="UserValidator"/> <property name="validator" ref="UserValidator"/>
</bean> </bean>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -23,6 +23,14 @@ body {
position: relative; position: relative;
} }
a{
color: #8d0000;
text-decoration: none;
}
a:hover{
color: #ea984b;
}
.login_error { .login_error {
color: #ff0000; color: #ff0000;
font-size: 10px; font-size: 10px;
@@ -203,7 +211,7 @@ form > table > thead th {
} }
#maincontent { #maincontent {
color: #333; color: #847d7d;
} }
@@ -276,6 +284,7 @@ table.content_table {
/* @end */ /* @end */
/* @group mainmenu */ /* @group mainmenu */
#main #mainmenu { #main #mainmenu {
@@ -361,6 +370,80 @@ table.content_table {
/* @end */ /* @end */
/* @group account data form */
#account_data p.legend {
font-weight:bold;
margin:10px 0px 3px 0px;
}
#account_data fieldset {
background-color: #fff8e1;
border: 1px solid #ffe7b3;
margin-right: 0px;
margin-bottom: 10px;
margin-top: 5px;
padding-left: 10px;
padding-right: 10px;
}
#account_data fieldset span.info {
float:right;
position:relative;
margin:-16px -10px 0px 0px;
font-size:11px;
}
#account_data fieldset div {
line-height:25px;
width: 700px;
}
#account_data fieldset div div{
line-height:25px;
width: 700px;
}
#account_data fieldset div label {
display:block;
float:left;
width:195px;
}
#account_data fieldset div input {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
color:#847d6e;
font-size:11px;
width:130px;
}
#account_data input:focus {
background-color: #fefed7;
}
#account_data fieldset div span {
color: #f00;
}
a.back_link {
text-decoration: none;
padding-left: 50px;
background: url(../images/button_back_32x32.gif) no-repeat left top;
padding-top: 10px;
padding-bottom: 10px;
color: #008281;
font-weight: bold;
}
a.back_link:hover{
color: #003e82;
}
div.user_new {
color: #847d6e;
font-weight: bold;
background: url(../images/user_new.png) no-repeat left top;
padding-left: 60px;
height: 40px;
padding-top: 15px;
}
/* @end */
/* @group globalfooter */ /* @group globalfooter */
#globalfooter { #globalfooter {

View File

@@ -58,6 +58,13 @@ public class ListConferenceController implements Controller{
model.put("errorMessage", msgCode); model.put("errorMessage", msgCode);
} }
// Create User before
String msgAccount = request.getParameter("account");
if (msgAccount != null)
{
model.put("ac", msgAccount);
}
return new ModelAndView("listConference", model); return new ModelAndView("listConference", model);
} }

View File

@@ -3,11 +3,18 @@
*/ */
package org.yacos.web.system.controller; package org.yacos.web.system.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.acegisecurity.providers.dao.DaoAuthenticationProvider;
import org.acegisecurity.providers.dao.UserCache;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController; import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.support.RequestContextUtils;
import org.springframework.web.servlet.view.RedirectView; import org.springframework.web.servlet.view.RedirectView;
import org.yacos.core.exceptions.PKAlreadyUsedException; import org.yacos.core.exceptions.PKAlreadyUsedException;
import org.yacos.core.exceptions.UserEMailAlreadyExistsException; import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
@@ -36,6 +43,7 @@ public class SUserRegistrationController extends SimpleFormController {
// Tries to retrieve the current user : case of user modification // Tries to retrieve the current user : case of user modification
User user = SessionService.getInstance().getCurrentUser(); User user = SessionService.getInstance().getCurrentUser();
Map<String, Object> model = new HashMap<String, Object>();
if( userCommand.getIsNew() ){ if( userCommand.getIsNew() ){
try { try {
@@ -46,6 +54,7 @@ public class SUserRegistrationController extends SimpleFormController {
userCommand.getLastName(), userCommand.getLastName(),
userCommand.getOrganization(), userCommand.getOrganization(),
userCommand.getEmail()); userCommand.getEmail());
model.put("account", "2");
} catch (PKAlreadyUsedException e) { } catch (PKAlreadyUsedException e) {
errors.rejectValue("login", "form.register.error.alreadyExists"); errors.rejectValue("login", "form.register.error.alreadyExists");
return new ModelAndView(new RedirectView(getFormView())); return new ModelAndView(new RedirectView(getFormView()));
@@ -61,16 +70,17 @@ public class SUserRegistrationController extends SimpleFormController {
if(userCommand.passwordWasModified()){ if(userCommand.passwordWasModified()){
user.setPassword(User.hashPassword(userCommand.getPassword())); user.setPassword(User.hashPassword(userCommand.getPassword()));
}
// Empty cache for the new password
DaoAuthenticationProvider authProvider = (DaoAuthenticationProvider) RequestContextUtils.getWebApplicationContext(request).getBean("daoAuthenticationProvider");
UserCache userCache = authProvider.getUserCache();
userCache.removeUserFromCache(user.getLogin());
}
userManager.UpdateUser(user); userManager.UpdateUser(user);
model.put("account", "1");
// Empty cache
//UserCache.removeUserFromCache(user.getLogin());
} }
return new ModelAndView(new RedirectView(getSuccessView())); return new ModelAndView(new RedirectView("listConference.htm"), model);
} }
/** /**
@@ -88,6 +98,9 @@ public class SUserRegistrationController extends SimpleFormController {
if(SessionService.getInstance().isUserLogged()){ if(SessionService.getInstance().isUserLogged()){
// If he is logged, we use his profile information to fill the form // If he is logged, we use his profile information to fill the form
currentUser = (User) SessionService.getInstance().getCurrentUser(); currentUser = (User) SessionService.getInstance().getCurrentUser();
// fill password field
user.setPasswordForRegisteredUser();
user.setIsNew(false); user.setIsNew(false);
} }
@@ -97,6 +110,8 @@ public class SUserRegistrationController extends SimpleFormController {
user.setEmail(currentUser.getEmail()); user.setEmail(currentUser.getEmail());
user.setOrganization(currentUser.getOrganization()); user.setOrganization(currentUser.getOrganization());
return user; return user;
} }

View File

@@ -24,14 +24,13 @@ public class FormUser {
public FormUser() { public FormUser() {
this.login = ""; this.login = "";
this.email = ""; this.email = "";
// We can't use the real password of the user, so we generate // We can't use the real password of the user, so we generate
// a hopefully unique placeholder value, that we will be able to check for modification at validation // a hopefully unique placeholder value, that we will be able to check for modification at validation
Random placeholderSeed = new Random(new Date().getTime()); Random placeholderSeed = new Random(new Date().getTime());
this.passwordPlaceholderValue = "placeholder"+placeholderSeed.nextInt(); this.passwordPlaceholderValue = "placeholder"+placeholderSeed.nextInt();
// For registration password="" but for editing call setPasswordForRegisteredUser method.
this.password = this.passwordPlaceholderValue; this.password = "";
this.passwordConfirm = this.passwordPlaceholderValue; this.passwordConfirm = "";
this.firstName = ""; this.firstName = "";
this.lastName = ""; this.lastName = "";
this.organization = ""; this.organization = "";
@@ -135,4 +134,10 @@ public class FormUser {
return isNew; return isNew;
} }
public void setPasswordForRegisteredUser() {
this.password = this.passwordPlaceholderValue;
this.passwordConfirm = this.passwordPlaceholderValue;
}
} }