Merge pull request #42 from egmp777/master

ChangesSept26
This commit is contained in:
Eugen 2014-09-27 01:48:24 +03:00
commit eb55fdbaad
27 changed files with 237 additions and 167 deletions

View File

@ -1,9 +1,10 @@
package org.baeldung.persistence.service; package org.baeldung.persistence.service;
import org.baeldung.persistence.model.User; import org.baeldung.persistence.model.User;
import org.baeldung.validation.service.EmailExistsException;
public interface IUserService { public interface IUserService {
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException; public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException;
} }

View File

@ -1,6 +1,9 @@
package org.baeldung.persistence.service; package org.baeldung.persistence.service;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.baeldung.validation.service.PasswordMatches;
import org.baeldung.validation.service.ValidEmail;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
@PasswordMatches @PasswordMatches
public class UserDto { public class UserDto {

View File

@ -1,9 +1,11 @@
package org.baeldung.persistence.service; package org.baeldung.persistence.service;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.dao.UserRepository;
import org.baeldung.persistence.model.Role; import org.baeldung.persistence.model.Role;
import org.baeldung.persistence.model.User; import org.baeldung.persistence.model.User;
import org.baeldung.validation.service.EmailExistsException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,16 +16,16 @@ public class UserService implements IUserService {
@Transactional @Transactional
@Override @Override
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException { public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException {
if (emailExist(userAccountData.getEmail())) { if (emailExist(accountDto.getEmail())) {
throw new EmailExistsException("There is an account with that email adress: " + userAccountData.getEmail()); throw new EmailExistsException("There is an account with that email adress: " + accountDto.getEmail());
} }
User user = new User(); User user = new User();
user.setFirstName(userAccountData.getFirstName()); user.setFirstName(accountDto.getFirstName());
user.setLastName(userAccountData.getLastName()); user.setLastName(accountDto.getLastName());
user.setPassword(userAccountData.getPassword()); user.setPassword(accountDto.getPassword());
user.setEmail(userAccountData.getEmail()); user.setEmail(accountDto.getEmail());
//ROLE WILL ALWAYS BE USER. HARDCODING IT //ROLE WILL ALWAYS BE USER. HARDCODING IT
user.setRole(new Role(Integer.valueOf(1),user)); user.setRole(new Role(Integer.valueOf(1),user));
return repository.save(user); return repository.save(user);

View File

@ -26,18 +26,12 @@ public class MyUserDetailsService implements UserDetailsService {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
// @Autowired
// public MyUserDetailsService(UserRepository repository) {
// this.userRepository = repository;
// }
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
try { try {
LOGGER.debug("Loading user by username: {}", email); LOGGER.debug("Loading user by username: {}", email);
User user = userRepository.findByEmail(email); User user = userRepository.findByEmail(email);
LOGGER.debug("Found user: {}", user); LOGGER.debug("Found user: {}", user);
if (user == null) { if (user == null) {
// throw new UsernameNotFoundException("No user found with username: " + username);
boolean enabled = false; boolean enabled = false;
return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1))); return new org.springframework.security.core.userdetails.User(" ", " ", enabled, true, true, true, getAuthorities(new Integer(1)));
} }
@ -52,7 +46,7 @@ public class MyUserDetailsService implements UserDetailsService {
} }
} }
public Collection<? extends GrantedAuthority> getAuthorities(Integer role) { private Collection<? extends GrantedAuthority> getAuthorities(Integer role) {
List<GrantedAuthority> authList = getGrantedAuthorities(getRoles(role)); List<GrantedAuthority> authList = getGrantedAuthorities(getRoles(role));
return authList; return authList;
} }
@ -61,17 +55,15 @@ public class MyUserDetailsService implements UserDetailsService {
List<String> roles = new ArrayList<String>(); List<String> roles = new ArrayList<String>();
if (role.intValue() == 2) { if (role.intValue() == 2) {
// roles.add("ROLE_USER");
roles.add("ROLE_ADMIN"); roles.add("ROLE_ADMIN");
} else if (role.intValue() == 1) { } else if (role.intValue() == 1) {
roles.add("ROLE_USER"); roles.add("ROLE_USER");
} }
return roles; return roles;
} }
public static List<GrantedAuthority> getGrantedAuthorities(List<String> roles) { private static List<GrantedAuthority> getGrantedAuthorities(List<String> roles) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
for (String role : roles) { for (String role : roles) {
authorities.add(new SimpleGrantedAuthority(role)); authorities.add(new SimpleGrantedAuthority(role));

View File

@ -2,8 +2,8 @@ package org.baeldung.spring;
import java.util.Locale; import java.util.Locale;
import org.baeldung.persistence.service.PasswordMatchesValidator; import org.baeldung.validation.service.EmailValidator;
import org.baeldung.persistence.service.EmailValidator; import org.baeldung.validation.service.PasswordMatchesValidator;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;

View File

@ -1,4 +1,4 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class EmailExistsException extends Throwable { public class EmailExistsException extends Throwable {

View File

@ -1,4 +1,4 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -20,7 +20,7 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
return (validateEmail(username)); return (validateEmail(username));
} }
public boolean validateEmail(String email) { private boolean validateEmail(String email) {
pattern = Pattern.compile(EMAIL_PATTERN); pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email); matcher = pattern.matcher(email);
return matcher.matches(); return matcher.matches();

View File

@ -1,4 +1,4 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
import javax.validation.Constraint; import javax.validation.Constraint;
import javax.validation.Payload; import javax.validation.Payload;

View File

@ -1,8 +1,10 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext; import javax.validation.ConstraintValidatorContext;
import org.baeldung.persistence.service.UserDto;
public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, Object> { public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, Object> {
@Override @Override

View File

@ -1,15 +1,11 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
import java.util.regex.Matcher; import org.baeldung.persistence.service.UserDto;
import java.util.regex.Pattern;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils; import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
public class UserValidator implements Validator { public class UserValidator implements Validator {
private Pattern pattern;
private Matcher matcher;
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
@Override @Override
public boolean supports(Class<?> clazz) { public boolean supports(Class<?> clazz) {
@ -24,10 +20,4 @@ public class UserValidator implements Validator {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "message.username", "UserName is required.");
} }
public boolean validateEmail(String email) {
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
} }

View File

@ -1,4 +1,4 @@
package org.baeldung.persistence.service; package org.baeldung.validation.service;
import javax.validation.Constraint; import javax.validation.Constraint;
import javax.validation.Payload; import javax.validation.Payload;

View File

@ -3,13 +3,12 @@ package org.baeldung.web.controller;
import javax.validation.Valid; import javax.validation.Valid;
import org.baeldung.persistence.model.User; import org.baeldung.persistence.model.User;
import org.baeldung.persistence.service.EmailExistsException;
import org.baeldung.persistence.service.UserDto; import org.baeldung.persistence.service.UserDto;
import org.baeldung.persistence.service.IUserService; import org.baeldung.persistence.service.IUserService;
import org.baeldung.validation.service.EmailExistsException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -25,8 +24,6 @@ public class RegistrationController {
private final Logger LOGGER = LoggerFactory.getLogger(getClass()); private final Logger LOGGER = LoggerFactory.getLogger(getClass());
private IUserService service; private IUserService service;
@Autowired
private MessageSource messages;
@Autowired @Autowired
public RegistrationController(IUserService service) { public RegistrationController(IUserService service) {
@ -42,34 +39,27 @@ public class RegistrationController {
} }
@RequestMapping(value = "/user/registration", method = RequestMethod.POST) @RequestMapping(value = "/user/registration", method = RequestMethod.POST)
public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto accountDto, BindingResult result, WebRequest request, Errors errors) {
User registered = new User(); User registered = new User();
if (!result.hasErrors()) if (!result.hasErrors())
registered = createUserAccount(userAccountData, result); registered = createUserAccount(accountDto, result);
if (registered == null) { if (registered == null) {
result.rejectValue("email", "message.regError"); result.rejectValue("email", "message.regError");
} }
if (result.hasErrors()) { if (result.hasErrors()) {
return new ModelAndView("registration", "user", userAccountData); return new ModelAndView("registration", "user", accountDto);
} else { } else {
// Will show the success registration page--ORIGINAL
return new ModelAndView("successRegister", "user", userAccountData);
// Will redirect to login view (not in url as login.html) and user model can be accessed return new ModelAndView("successRegister", "user", accountDto);
// return new ModelAndView("login","user", userAccountData);
// Will redirect to login html but no model object---we send a success param to the login form
//return new ModelAndView("redirect:/login.html?success=true", "", null);
} }
} }
private User createUserAccount(UserDto userAccountData, BindingResult result) { private User createUserAccount(UserDto accountDto, BindingResult result) {
User registered = null; User registered = null;
try { try {
registered = service.registerNewUserAccount(userAccountData); registered = service.registerNewUserAccount(accountDto);
} catch (EmailExistsException e) { } catch (EmailExistsException e) {
return null; return null;
} }

View File

@ -1,10 +1,10 @@
################### DataSource Configuration ########################## ################### DataSource Configuration ##########################
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA
jdbc.user=tutorialuser jdbc.user=tutorialuser
jdbc.pass=tutorialmy5ql jdbc.pass=tutorialmy5ql
init-db=false init-db=false
################### Hibernate Configuration ########################## ################### Hibernate Configuration ##########################
hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop hibernate.hbm2ddl.auto=validate

View File

@ -25,6 +25,13 @@ label.form.loginPass=Password
label.form.loginEnglish=English label.form.loginEnglish=English
label.form.loginSpanish=Spanish label.form.loginSpanish=Spanish
label.form.loginSignUp=Sign up label.form.loginSignUp=Sign up
label.pages.logout=Logout
label.pages.admin=Administrator
label.pages.home.title=Home
label.pages.home.message=Welcome Home
label.pages.admin.message=Welcome Admin
label.pages.user.message=Welcome User
label.successRegister.title=Registration Success
ValidEmail.user.email=Invalid email address! ValidEmail.user.email=Invalid email address!
UniqueUsername.user.username=An account with that username/email already exists UniqueUsername.user.username=An account with that username/email already exists
NotNull.user.firstName=First name required NotNull.user.firstName=First name required

View File

@ -25,6 +25,13 @@ label.form.loginPass=Contrasenia
label.form.loginEnglish=Ingles label.form.loginEnglish=Ingles
label.form.loginSpanish=Espaniol label.form.loginSpanish=Espaniol
label.form.loginSignUp=Registrese label.form.loginSignUp=Registrese
label.pages.logout=Salir
label.pages.admin=Administrador
label.pages.home.title=Inicio
label.pages.home.message=Bienveni@ a Casa
label.pages.admin.message=Bienvenido Admin
label.pages.user.message=Bienvenido Usuario
label.successRegister.title=Registro Exitoso
ValidEmail.user.email=Cuenta correo invlida! ValidEmail.user.email=Cuenta correo invlida!
UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario
NotNull.user.firstName=Por favor ingrese su nombre NotNull.user.firstName=Por favor ingrese su nombre

View File

@ -4,7 +4,7 @@
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation=" xsi:schemaLocation="
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<http use-expressions="true"> <http use-expressions="true">
<intercept-url pattern="/login*" access="permitAll" /> <intercept-url pattern="/login*" access="permitAll" />
<intercept-url pattern="/logout*" access="permitAll" /> <intercept-url pattern="/logout*" access="permitAll" />

View File

@ -2,6 +2,6 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
</beans> </beans>

View File

@ -8,14 +8,21 @@
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
</head> </head>
<body> <body>
<sec:authorize ifAnyGranted="ROLE_USER"> <div class="container">
<spring:message code="message.unauth"></spring:message> <div class="span12">
</sec:authorize> <sec:authorize ifAnyGranted="ROLE_USER">
<sec:authorize ifAnyGranted="ROLE_ADMIN"> <spring:message code="message.unauth"></spring:message>
<H1>Hello Admin</H1> </sec:authorize>
</sec:authorize> <sec:authorize ifAnyGranted="ROLE_ADMIN">
<H1>
<a href="<c:url value="/j_spring_security_logout" />">Logout</a> <spring:message code="label.pages.admin.message"></spring:message>
<a href="<c:url value="/home.html" />">Home</a> </H1>
</sec:authorize>
<a href="<c:url value="/j_spring_security_logout" />"><spring:message
code="label.pages.logout"></spring:message></a> <a
href="<c:url value="/home.html" />"><spring:message
code="label.pages.home.title"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,22 +1,29 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%> uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
</head> </head>
<body> <body>
<h1>This is the landing page for the admin</h1> <div class="container">
<sec:authorize access="hasRole('ROLE_USER')"> <div class="span12">
<h1>This is the landing page for the admin</h1>
<sec:authorize access="hasRole('ROLE_USER')">
This text is only visible to a user This text is only visible to a user
<br /> <br />
</sec:authorize> </sec:authorize>
<sec:authorize access="hasRole('ROLE_ADMIN')"> <sec:authorize access="hasRole('ROLE_ADMIN')">
This text is only visible to an admin This text is only visible to an admin
<br /> <br />
</sec:authorize> </sec:authorize>
<a href="<c:url value="/j_spring_security_logout" />">Logout</a> <a href="<c:url value="/j_spring_security_logout" />"><spring:message
<a href="<c:url value="/admin.html" />">Administrator Page</a> code="label.pages.logout"></spring:message></a> <a
href="<c:url value="/admin.html" />"><spring:message
code="label.pages.admin"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,13 +1,22 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="true"%> <%@ page session="true"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
<title>Home</title> <title><spring:message code="label.pages.home.title"></spring:message></title>
</head> </head>
<body> <body>
<h1>Welcome back home!</h1> <div class="container">
<div class="span12">
<h1>
<spring:message code="label.pages.home.message"></spring:message>
</h1>
<a href="<c:url value="/j_spring_security_logout" />"><spring:message
code="label.pages.logout"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,25 +1,31 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ page session="true"%> <%@ page session="true"%>
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
</head> </head>
<body> <body>
<h1>This is the homepage for the user</h1> <div class="container">
<div class="span12">
<sec:authorize access="hasRole('ROLE_USER')">
<spring:message code="label.pages.user.message"></spring:message>
<br />
</sec:authorize>
<sec:authorize access="hasRole('ROLE_USER')"> <sec:authorize access="hasRole('ROLE_ADMIN')">
This text is only visible to a user <spring:message code="label.pages.admin.message"></spring:message>
<br /> <br />
</sec:authorize> </sec:authorize>
<a href="<c:url value="/j_spring_security_logout" />"><spring:message
<sec:authorize access="hasRole('ROLE_ADMIN')"> code="label.pages.logout"></spring:message></a> <a
This text is only visible to an admin href="<c:url value="/home.html" />"><spring:message
<br /> code="label.pages.home.title"></spring:message></a> <a
</sec:authorize> href="<c:url value="/admin.html" />"><spring:message
code="label.pages.admin"></spring:message></a>
<a href="<c:url value="/j_spring_security_logout" />">Logout</a> </div>
<a href="<c:url value="/home.html" />">Home</a> </div>
<a href="<c:url value="/admin.html" />">Administrator Page</a>
</body> </body>
</html> </html>

View File

@ -3,12 +3,18 @@
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
<title>Home</title> <title><spring:message code="label.pages.home.title"></spring:message></title>
</head> </head>
<body> <body>
<h1 class="alert alert-error"> <div class="container">
<spring:message code="message.sessionExpired"></spring:message> <div class="span12">
</h1> <h1 class="alert alert-error">
<spring:message code="message.sessionExpired"></spring:message>
</h1>
<a href="<c:url value="login.html" />"><spring:message
code="label.form.loginLink"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,5 +1,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<fmt:setBundle basename="messages" /> <fmt:setBundle basename="messages" />
@ -11,8 +12,12 @@
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
<c:if test="${param.error != null}"> <c:if test="${param.error != null}">
<div class="alert alert-error"> <div class="container">
<spring:message code="message.badCredentials"></spring:message> <div class="span12">
<div class="alert alert-error">
<spring:message code="message.badCredentials"></spring:message>
</div>
</div>
</div> </div>
</c:if> </c:if>
<script type="text/javascript"> <script type="text/javascript">
@ -37,28 +42,39 @@
</script> </script>
</head> </head>
<body> <body>
<h1><spring:message code="label.form.loginTitle"></spring:message></h1> <div class="container">
<a href="?lang=en"><spring:message code="label.form.loginEnglish"></spring:message></a> | <div class="span12">
<a href="?lang=es_ES"><spring:message code="label.form.loginSpanish"></spring:message></a> <h1>
<form name='f' action="j_spring_security_check" method='POST' onsubmit="return validate();"> <spring:message code="label.form.loginTitle"></spring:message>
<table> </h1>
<tr> <a href="?lang=en"><spring:message code="label.form.loginEnglish"></spring:message></a>
<td><label><spring:message code="label.form.loginEmail"></spring:message></label></td> | <a href="?lang=es_ES"><spring:message
<td><input type='text' name='j_username' value=''></td> code="label.form.loginSpanish"></spring:message></a>
</tr> <form name='f' action="j_spring_security_check" method='POST'
<tr> onsubmit="return validate();">
<td><label><spring:message code="label.form.loginPass"></spring:message></label></td> <table>
<td><input type='password' name='j_password' /></td> <tr>
</tr> <td><label><spring:message
<tr> code="label.form.loginEmail"></spring:message></label></td>
<td><input name="submit" type="submit" value=<spring:message code="label.form.submit"></spring:message> /></td> <td><input type='text' name='j_username' value=''></td>
</tr> </tr>
</table> <tr>
<td><label><spring:message
code="label.form.loginPass"></spring:message></label></td>
<td><input type='password' name='j_password' /></td>
</tr>
<tr>
<td><input name="submit" type="submit"
value=<spring:message code="label.form.submit"></spring:message> /></td>
</tr>
</table>
</form> </form>
<br> Current Locale : ${pageContext.response.locale} <br> Current Locale : ${pageContext.response.locale} <br> <a
<br> href="<c:url value="/user/registration" />"><spring:message
<a href="<c:url value="/user/registration" />"><spring:message code="label.form.loginSignUp"></spring:message></a> code="label.form.loginSignUp"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,5 +1,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html> <html>
@ -15,12 +16,17 @@
</head> </head>
<body> <body>
<c:if test="${param.logSucc == true}"> <div class="container">
<div id="success"> <div class="span12">
<spring:message code="message.logoutSucc"></spring:message> <c:if test="${param.logSucc == true}">
<div id="success">
<spring:message code="message.logoutSucc"></spring:message>
</div>
</c:if>
<a href="<c:url value="login.html" />"><spring:message
code="label.form.loginLink"></spring:message></a>
</div>
</div> </div>
</c:if>
<a href="login.html">Login</a>
</body> </body>
</html> </html>

View File

@ -3,7 +3,8 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ 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="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@ page session="false"%> <%@ page session="false"%>
<html> <html>
<head> <head>
@ -11,40 +12,53 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title><spring:message code="label.form.title"></spring:message></title> <title><spring:message code="label.form.title"></spring:message></title>
</head> </head>
<body> <body>
<H1><spring:message code="label.form.title"></spring:message></H1> <div class="container">
<form:form modelAttribute="user" method="POST" enctype="utf8" > <div class="span12">
<br> <H1>
<tr> <spring:message code="label.form.title"></spring:message>
<td><label><spring:message code="label.user.firstName"></spring:message></label></td> </H1>
<td><form:input path="firstName" value="" /></td> <form:form modelAttribute="user" method="POST" enctype="utf8">
<form:errors path="firstName" cssClass="alert alert-error" element="div" /> <br>
</tr> <tr>
<tr> <td><label><spring:message code="label.user.firstName"></spring:message></label></td>
<td><label><spring:message code="label.user.lastName"></spring:message></label></td> <td><form:input path="firstName" value="" /></td>
<td><form:input path="lastName" value="" /></td> <form:errors path="firstName" cssClass="alert alert-error"
<form:errors path="lastName" cssClass="alert alert-error" element="div" /> element="div" />
</tr> </tr>
<tr> <tr>
<td><label><spring:message code="label.user.email"></spring:message></label></td> <td><label><spring:message code="label.user.lastName"></spring:message></label></td>
<td><form:input path="email" value="" /></td> <td><form:input path="lastName" value="" /></td>
<form:errors path="email" cssClass="alert alert-error" element="div" /> <form:errors path="lastName" cssClass="alert alert-error"
</tr> element="div" />
<tr> </tr>
<td><label><spring:message code="label.user.password"></spring:message></label></td> <tr>
<td><form:input path="password" value="" type="password" /></td> <td><label><spring:message code="label.user.email"></spring:message></label></td>
<form:errors path="password" cssClass="alert alert-error" element="div" /> <td><form:input path="email" value="" /></td>
</tr> <form:errors path="email" cssClass="alert alert-error"
<tr> element="div" />
<td><label><spring:message code="label.user.confirmPass"></spring:message></label></td> </tr>
<td><form:input path="matchingPassword" value="" type="password"/></td> <tr>
<form:errors cssClass="alert alert-error" element="div" /> <td><label><spring:message code="label.user.password"></spring:message></label></td>
</tr> <td><form:input path="password" value="" type="password" /></td>
<button type="submit"><spring:message code="label.form.submit"></spring:message></button> <form:errors path="password" cssClass="alert alert-error"
</form:form> element="div" />
<br> </tr>
<a href="<c:url value="login.html" />"><spring:message code="label.form.loginLink"></spring:message></a> <tr>
<td><label><spring:message
code="label.user.confirmPass"></spring:message></label></td>
<td><form:input path="matchingPassword" value=""
type="password" /></td>
<form:errors cssClass="alert alert-error" element="div" />
</tr>
<button type="submit">
<spring:message code="label.form.submit"></spring:message>
</button>
</form:form>
<br> <a href="<c:url value="login.html" />"><spring:message
code="label.form.loginLink"></spring:message></a>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,5 +1,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<fmt:setBundle basename="messages" /> <fmt:setBundle basename="messages" />
@ -13,10 +14,14 @@
<title>Registration Success</title> <title>Registration Success</title>
</head> </head>
<body> <body>
<div id="success"> <div class="container">
<spring:message code="message.regSucc"></spring:message> <div class="span12">
<div id="success">
<spring:message code="message.regSucc"></spring:message>
</div>
<a href="<c:url value="login.html" />"><spring:message
code="label.login"></spring:message></a>
</div>
</div> </div>
<a href="<c:url value="login.html" />"><spring:message code="label.login"></spring:message></a>
</body> </body>
</html> </html>

View File

@ -1091,7 +1091,7 @@ input[type="tel"],
input[type="color"], input[type="color"],
.uneditable-input { .uneditable-input {
display: inline-block; display: inline-block;
height: 20px; height: 30px;
padding: 4px 6px; padding: 4px 6px;
margin-bottom: 10px; margin-bottom: 10px;
font-size: 14px; font-size: 14px;