cleanup work (mostly formating)
This commit is contained in:
parent
f0b106ab60
commit
bb662b4252
@ -18,13 +18,11 @@ public class MyController {
|
|||||||
* information in the event of an unsuccessful login attempt).
|
* information in the event of an unsuccessful login attempt).
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
||||||
public ModelAndView login(
|
public ModelAndView login(@RequestParam(value = "error", required = false) String error) {
|
||||||
@RequestParam(value = "error", required = false) String error) {
|
|
||||||
|
|
||||||
ModelAndView model = new ModelAndView();
|
ModelAndView model = new ModelAndView();
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
model.addObject("message",
|
model.addObject("message", "Username or password not recognised - please try again.");
|
||||||
"Username or password not recognised - please try again.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model.setViewName("login");
|
model.setViewName("login");
|
||||||
|
@ -6,7 +6,6 @@ package org.baeldung.security;
|
|||||||
*/
|
*/
|
||||||
public enum SecurityRole {
|
public enum SecurityRole {
|
||||||
|
|
||||||
ROLE_USER,
|
ROLE_USER, ROLE_ADMIN;
|
||||||
ROLE_ADMIN;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String username)
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
throws UsernameNotFoundException {
|
|
||||||
|
|
||||||
logger.info("Load user by username " + username);
|
logger.info("Load user by username " + username);
|
||||||
|
|
||||||
@ -56,13 +55,10 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||||||
|
|
||||||
logger.info("Populate demo users");
|
logger.info("Populate demo users");
|
||||||
|
|
||||||
availableUsers.put("user",
|
availableUsers.put("user", createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER)));
|
||||||
createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER)));
|
availableUsers.put("admin", createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN)));
|
||||||
availableUsers.put("admin",
|
|
||||||
createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a demo User.
|
* Create a demo User.
|
||||||
*
|
*
|
||||||
|
@ -23,5 +23,3 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user