I am trying to create a login page which will log in into the specific account depending on which role does the user have but for some reason the spring security never recogonizes the username and password
Here is the LoginController
package login_page
import grails.plugin.springsecurity.userdetails.DefaultPostAuthenticationChecks import org.springframework.security.access.annotation.Secured
@Secured('permitAll') class LoginController extends grails.plugin.springsecurity.LoginController {
PersonService personService
def index() {
if (isLoggedIn()) {
redirect uri: conf.successHandler.defaultTargetUrl
}
else {
redirect action: 'auth', params: params
}
}
def auth() {
def conf = getConf()
if (isLoggedIn()) {
redirect uri: conf.successHandler.defaultTargetUrl
return
}
String postUrl = request.contextPath + conf.apf.filterProcessesUrl
render view: 'index', model: [postUrl: postUrl,
rememberMeParameter: conf.rememberMe.parameter,
usernameParameter: conf.apf.usernameParameter,
passwordParameter: conf.apf.passwordParameter,
]
}
}
and success uri is /person/LoginPage
and the LoginPage method is this
@Secured(['ROLE_USER','ROLE_ADMIN','ROLE_SUPERADMIN'])
def LoginPage() {
refreshCurrentUser()
if (currentPerson == null) {
notFound()
}else {
if(currentPerson.getAuthorities()[0].getAuthority()=="ROLE_SUPERADMIN"){
redirect(controller:'superAdmin', action: 'superAdminShow', id: currentPerson.id)
}
else if(currentPerson.getAuthorities()[0].getAuthority()=="ROLE_ADMIN"){
redirect(controller:'admin', action: 'adminShow', id: currentPerson.id)
}
else if(currentPerson.getAuthorities()[0].getAuthority()=="ROLE_USER"){
redirect(action: 'show', id: currentPerson.id)
}
}
}