commit
eb55fdbaad
|
@ -1,9 +1,10 @@
|
|||
package org.baeldung.persistence.service;
|
||||
|
||||
import org.baeldung.persistence.model.User;
|
||||
import org.baeldung.validation.service.EmailExistsException;
|
||||
|
||||
public interface IUserService {
|
||||
|
||||
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException;
|
||||
public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.baeldung.persistence.service;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.baeldung.validation.service.PasswordMatches;
|
||||
import org.baeldung.validation.service.ValidEmail;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
@PasswordMatches
|
||||
public class UserDto {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package org.baeldung.persistence.service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.baeldung.persistence.dao.UserRepository;
|
||||
import org.baeldung.persistence.model.Role;
|
||||
import org.baeldung.persistence.model.User;
|
||||
import org.baeldung.validation.service.EmailExistsException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -14,16 +16,16 @@ public class UserService implements IUserService {
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public User registerNewUserAccount(UserDto userAccountData) throws EmailExistsException {
|
||||
if (emailExist(userAccountData.getEmail())) {
|
||||
public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException {
|
||||
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.setFirstName(userAccountData.getFirstName());
|
||||
user.setLastName(userAccountData.getLastName());
|
||||
user.setPassword(userAccountData.getPassword());
|
||||
user.setEmail(userAccountData.getEmail());
|
||||
user.setFirstName(accountDto.getFirstName());
|
||||
user.setLastName(accountDto.getLastName());
|
||||
user.setPassword(accountDto.getPassword());
|
||||
user.setEmail(accountDto.getEmail());
|
||||
//ROLE WILL ALWAYS BE USER. HARDCODING IT
|
||||
user.setRole(new Role(Integer.valueOf(1),user));
|
||||
return repository.save(user);
|
||||
|
|
|
@ -26,18 +26,12 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
// @Autowired
|
||||
// public MyUserDetailsService(UserRepository repository) {
|
||||
// this.userRepository = repository;
|
||||
// }
|
||||
|
||||
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
|
||||
try {
|
||||
LOGGER.debug("Loading user by username: {}", email);
|
||||
User user = userRepository.findByEmail(email);
|
||||
LOGGER.debug("Found user: {}", user);
|
||||
if (user == null) {
|
||||
// throw new UsernameNotFoundException("No user found with username: " + username);
|
||||
boolean enabled = false;
|
||||
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));
|
||||
return authList;
|
||||
}
|
||||
|
@ -61,17 +55,15 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||
List<String> roles = new ArrayList<String>();
|
||||
|
||||
if (role.intValue() == 2) {
|
||||
// roles.add("ROLE_USER");
|
||||
roles.add("ROLE_ADMIN");
|
||||
|
||||
} else if (role.intValue() == 1) {
|
||||
roles.add("ROLE_USER");
|
||||
}
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
public static List<GrantedAuthority> getGrantedAuthorities(List<String> roles) {
|
||||
private static List<GrantedAuthority> getGrantedAuthorities(List<String> roles) {
|
||||
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
|
||||
for (String role : roles) {
|
||||
authorities.add(new SimpleGrantedAuthority(role));
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.baeldung.spring;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.baeldung.persistence.service.PasswordMatchesValidator;
|
||||
import org.baeldung.persistence.service.EmailValidator;
|
||||
import org.baeldung.validation.service.EmailValidator;
|
||||
import org.baeldung.validation.service.PasswordMatchesValidator;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class EmailExistsException extends Throwable {
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -20,7 +20,7 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
|||
return (validateEmail(username));
|
||||
}
|
||||
|
||||
public boolean validateEmail(String email) {
|
||||
private boolean validateEmail(String email) {
|
||||
pattern = Pattern.compile(EMAIL_PATTERN);
|
||||
matcher = pattern.matcher(email);
|
||||
return matcher.matches();
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
|
@ -1,8 +1,10 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
import org.baeldung.persistence.service.UserDto;
|
||||
|
||||
public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, Object> {
|
||||
|
||||
@Override
|
|
@ -1,15 +1,11 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.baeldung.persistence.service.UserDto;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.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
|
||||
public boolean supports(Class<?> clazz) {
|
||||
|
@ -24,10 +20,4 @@ public class UserValidator implements Validator {
|
|||
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();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.persistence.service;
|
||||
package org.baeldung.validation.service;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
|
@ -3,13 +3,12 @@ package org.baeldung.web.controller;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import org.baeldung.persistence.model.User;
|
||||
import org.baeldung.persistence.service.EmailExistsException;
|
||||
import org.baeldung.persistence.service.UserDto;
|
||||
import org.baeldung.persistence.service.IUserService;
|
||||
import org.baeldung.validation.service.EmailExistsException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
@ -25,8 +24,6 @@ public class RegistrationController {
|
|||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
|
||||
private IUserService service;
|
||||
@Autowired
|
||||
private MessageSource messages;
|
||||
|
||||
@Autowired
|
||||
public RegistrationController(IUserService service) {
|
||||
|
@ -42,34 +39,27 @@ public class RegistrationController {
|
|||
}
|
||||
|
||||
@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();
|
||||
if (!result.hasErrors())
|
||||
registered = createUserAccount(userAccountData, result);
|
||||
registered = createUserAccount(accountDto, result);
|
||||
if (registered == null) {
|
||||
result.rejectValue("email", "message.regError");
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
return new ModelAndView("registration", "user", userAccountData);
|
||||
return new ModelAndView("registration", "user", accountDto);
|
||||
} 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("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);
|
||||
return new ModelAndView("successRegister", "user", accountDto);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private User createUserAccount(UserDto userAccountData, BindingResult result) {
|
||||
private User createUserAccount(UserDto accountDto, BindingResult result) {
|
||||
User registered = null;
|
||||
try {
|
||||
registered = service.registerNewUserAccount(userAccountData);
|
||||
registered = service.registerNewUserAccount(accountDto);
|
||||
} catch (EmailExistsException e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
################### DataSource Configuration ##########################
|
||||
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.pass=tutorialmy5ql
|
||||
init-db=false
|
||||
################### Hibernate Configuration ##########################
|
||||
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
hibernate.show_sql=true
|
||||
hibernate.hbm2ddl.auto=validate
|
||||
|
|
|
@ -25,6 +25,13 @@ label.form.loginPass=Password
|
|||
label.form.loginEnglish=English
|
||||
label.form.loginSpanish=Spanish
|
||||
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!
|
||||
UniqueUsername.user.username=An account with that username/email already exists
|
||||
NotNull.user.firstName=First name required
|
||||
|
|
|
@ -25,6 +25,13 @@ label.form.loginPass=Contrasenia
|
|||
label.form.loginEnglish=Ingles
|
||||
label.form.loginSpanish=Espaniol
|
||||
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!
|
||||
UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario
|
||||
NotNull.user.firstName=Por favor ingrese su nombre
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="
|
||||
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">
|
||||
<intercept-url pattern="/login*" access="permitAll" />
|
||||
<intercept-url pattern="/logout*" access="permitAll" />
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
<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: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>
|
|
@ -8,14 +8,21 @@
|
|||
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<sec:authorize ifAnyGranted="ROLE_USER">
|
||||
<spring:message code="message.unauth"></spring:message>
|
||||
</sec:authorize>
|
||||
<sec:authorize ifAnyGranted="ROLE_ADMIN">
|
||||
<H1>Hello Admin</H1>
|
||||
<H1>
|
||||
<spring:message code="label.pages.admin.message"></spring:message>
|
||||
</H1>
|
||||
</sec:authorize>
|
||||
|
||||
<a href="<c:url value="/j_spring_security_logout" />">Logout</a>
|
||||
<a href="<c:url value="/home.html" />">Home</a>
|
||||
<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>
|
||||
</html>
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="sec"
|
||||
uri="http://www.springframework.org/security/tags"%>
|
||||
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||
<html>
|
||||
<head>
|
||||
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<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
|
||||
|
@ -15,8 +18,12 @@
|
|||
This text is only visible to an admin
|
||||
<br />
|
||||
</sec:authorize>
|
||||
<a href="<c:url value="/j_spring_security_logout" />">Logout</a>
|
||||
<a href="<c:url value="/admin.html" />">Administrator Page</a>
|
||||
<a href="<c:url value="/j_spring_security_logout" />"><spring:message
|
||||
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>
|
||||
|
||||
</html>
|
|
@ -1,13 +1,22 @@
|
|||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
||||
<%@ page session="true"%>
|
||||
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,25 +1,31 @@
|
|||
<%@ 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"%>
|
||||
<html>
|
||||
<head>
|
||||
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<h1>This is the homepage for the user</h1>
|
||||
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<sec:authorize access="hasRole('ROLE_USER')">
|
||||
This text is only visible to a user
|
||||
<spring:message code="label.pages.user.message"></spring:message>
|
||||
<br />
|
||||
</sec:authorize>
|
||||
|
||||
<sec:authorize access="hasRole('ROLE_ADMIN')">
|
||||
This text is only visible to an admin
|
||||
<spring:message code="label.pages.admin.message"></spring:message>
|
||||
<br />
|
||||
</sec:authorize>
|
||||
|
||||
<a href="<c:url value="/j_spring_security_logout" />">Logout</a>
|
||||
<a href="<c:url value="/home.html" />">Home</a>
|
||||
<a href="<c:url value="/admin.html" />">Administrator Page</a>
|
||||
<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> <a
|
||||
href="<c:url value="/admin.html" />"><spring:message
|
||||
code="label.pages.admin"></spring:message></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -3,12 +3,18 @@
|
|||
<html>
|
||||
<head>
|
||||
<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>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<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>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<%@ 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://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||
<fmt:setBundle basename="messages" />
|
||||
|
@ -11,9 +12,13 @@
|
|||
<head>
|
||||
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
|
||||
<c:if test="${param.error != null}">
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<div class="alert alert-error">
|
||||
<spring:message code="message.badCredentials"></spring:message>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
<script type="text/javascript">
|
||||
function validate() {
|
||||
|
@ -37,28 +42,39 @@
|
|||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1><spring:message code="label.form.loginTitle"></spring:message></h1>
|
||||
<a href="?lang=en"><spring:message code="label.form.loginEnglish"></spring:message></a> |
|
||||
<a href="?lang=es_ES"><spring:message code="label.form.loginSpanish"></spring:message></a>
|
||||
<form name='f' action="j_spring_security_check" method='POST' onsubmit="return validate();">
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<h1>
|
||||
<spring:message code="label.form.loginTitle"></spring:message>
|
||||
</h1>
|
||||
<a href="?lang=en"><spring:message code="label.form.loginEnglish"></spring:message></a>
|
||||
| <a href="?lang=es_ES"><spring:message
|
||||
code="label.form.loginSpanish"></spring:message></a>
|
||||
<form name='f' action="j_spring_security_check" method='POST'
|
||||
onsubmit="return validate();">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.form.loginEmail"></spring:message></label></td>
|
||||
<td><label><spring:message
|
||||
code="label.form.loginEmail"></spring:message></label></td>
|
||||
<td><input type='text' name='j_username' value=''></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.form.loginPass"></spring:message></label></td>
|
||||
<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>
|
||||
<td><input name="submit" type="submit"
|
||||
value=<spring:message code="label.form.submit"></spring:message> /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
<br> Current Locale : ${pageContext.response.locale}
|
||||
<br>
|
||||
<a href="<c:url value="/user/registration" />"><spring:message code="label.form.loginSignUp"></spring:message></a>
|
||||
<br> Current Locale : ${pageContext.response.locale} <br> <a
|
||||
href="<c:url value="/user/registration" />"><spring:message
|
||||
code="label.form.loginSignUp"></spring:message></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,5 +1,6 @@
|
|||
<%@ 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"%>
|
||||
<html>
|
||||
|
||||
|
@ -15,12 +16,17 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<c:if test="${param.logSucc == true}">
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<c:if test="${param.logSucc == true}">
|
||||
<div id="success">
|
||||
<spring:message code="message.logoutSucc"></spring:message>
|
||||
</div>
|
||||
</c:if>
|
||||
<a href="login.html">Login</a>
|
||||
</c:if>
|
||||
<a href="<c:url value="login.html" />"><spring:message
|
||||
code="label.form.loginLink"></spring:message></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -3,7 +3,8 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ 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"%>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -11,40 +12,53 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title><spring:message code="label.form.title"></spring:message></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<H1><spring:message code="label.form.title"></spring:message></H1>
|
||||
<form:form modelAttribute="user" method="POST" enctype="utf8" >
|
||||
<div class="container">
|
||||
<div class="span12">
|
||||
<H1>
|
||||
<spring:message code="label.form.title"></spring:message>
|
||||
</H1>
|
||||
<form:form modelAttribute="user" method="POST" enctype="utf8">
|
||||
<br>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.user.firstName"></spring:message></label></td>
|
||||
<td><form:input path="firstName" value="" /></td>
|
||||
<form:errors path="firstName" cssClass="alert alert-error" element="div" />
|
||||
<form:errors path="firstName" cssClass="alert alert-error"
|
||||
element="div" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.user.lastName"></spring:message></label></td>
|
||||
<td><form:input path="lastName" value="" /></td>
|
||||
<form:errors path="lastName" cssClass="alert alert-error" element="div" />
|
||||
<form:errors path="lastName" cssClass="alert alert-error"
|
||||
element="div" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.user.email"></spring:message></label></td>
|
||||
<td><form:input path="email" value="" /></td>
|
||||
<form:errors path="email" cssClass="alert alert-error" element="div" />
|
||||
<form:errors path="email" cssClass="alert alert-error"
|
||||
element="div" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.user.password"></spring:message></label></td>
|
||||
<td><form:input path="password" value="" type="password" /></td>
|
||||
<form:errors path="password" cssClass="alert alert-error" element="div" />
|
||||
<form:errors path="password" cssClass="alert alert-error"
|
||||
element="div" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><spring:message code="label.user.confirmPass"></spring:message></label></td>
|
||||
<td><form:input path="matchingPassword" value="" type="password"/></td>
|
||||
<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>
|
||||
<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>
|
||||
<br> <a href="<c:url value="login.html" />"><spring:message
|
||||
code="label.form.loginLink"></spring:message></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,5 +1,6 @@
|
|||
<%@ 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://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||
<fmt:setBundle basename="messages" />
|
||||
|
@ -13,10 +14,14 @@
|
|||
<title>Registration Success</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<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>
|
||||
<a href="<c:url value="login.html" />"><spring:message
|
||||
code="label.login"></spring:message></a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1091,7 +1091,7 @@ input[type="tel"],
|
|||
input[type="color"],
|
||||
.uneditable-input {
|
||||
display: inline-block;
|
||||
height: 20px;
|
||||
height: 30px;
|
||||
padding: 4px 6px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 14px;
|
||||
|
|
Loading…
Reference in New Issue