|
15 | 15 | package grails.plugin.springsecurity
|
16 | 16 |
|
17 | 17 | import grails.converters.JSON
|
| 18 | +import org.grails.web.servlet.mvc.GrailsWebRequest |
18 | 19 | import org.springframework.context.MessageSource
|
19 | 20 | import org.springframework.security.access.annotation.Secured
|
20 | 21 | import org.springframework.security.authentication.AccountExpiredException
|
@@ -104,18 +105,19 @@ class LoginController {
|
104 | 105 | String msg = ''
|
105 | 106 | def exception = session[WebAttributes.AUTHENTICATION_EXCEPTION]
|
106 | 107 | if (exception) {
|
| 108 | + def locale = GrailsWebRequest.lookup().getLocale() ?: Locale.getDefault() |
107 | 109 | if (exception instanceof AccountExpiredException) {
|
108 |
| - msg = messageSource.getMessage('springSecurity.errors.login.expired', null, "Account Expired", request.locale) |
| 110 | + msg = messageSource.getMessage('springSecurity.errors.login.expired', null, "Account Expired", locale) |
109 | 111 | } else if (exception instanceof CredentialsExpiredException) {
|
110 |
| - msg = messageSource.getMessage('springSecurity.errors.login.passwordExpired', null, "Password Expired", request.locale) |
| 112 | + msg = messageSource.getMessage('springSecurity.errors.login.passwordExpired', null, "Password Expired", locale) |
111 | 113 | } else if (exception instanceof DisabledException) {
|
112 |
| - msg = messageSource.getMessage('springSecurity.errors.login.disabled', null, "Account Disabled", request.locale) |
| 114 | + msg = messageSource.getMessage('springSecurity.errors.login.disabled', null, "Account Disabled", locale) |
113 | 115 | } else if (exception instanceof LockedException) {
|
114 |
| - msg = messageSource.getMessage('springSecurity.errors.login.locked', null, "Account Locked", request.locale) |
| 116 | + msg = messageSource.getMessage('springSecurity.errors.login.locked', null, "Account Locked", locale) |
115 | 117 | } else if (exception instanceof SessionAuthenticationException) {
|
116 |
| - msg = messageSource.getMessage('springSecurity.errors.login.max.sessions.exceeded', null, "Sorry, you have exceeded your maximum number of open sessions.", request.locale) |
| 118 | + msg = messageSource.getMessage('springSecurity.errors.login.max.sessions.exceeded', null, "Sorry, you have exceeded your maximum number of open sessions.", locale) |
117 | 119 | } else {
|
118 |
| - msg = messageSource.getMessage('springSecurity.errors.login.fail', null, "Authentication Failure", request.locale) |
| 120 | + msg = messageSource.getMessage('springSecurity.errors.login.fail', null, "Authentication Failure", locale) |
119 | 121 | }
|
120 | 122 | }
|
121 | 123 |
|
|
0 commit comments