我已经实现了 SecureSocial 模块并通过它提供登录。对于不同的用户,我已经映射了不同的角色并在主控制器应用程序中检查登录后重定向。
public class Application extends Controller {
/**
* This action only gets called if the user is logged in.
*
* @return
*/
@SecureSocial.SecuredAction
public static Result index() {
User currentUser = User.findByEmail(SecureSocial.currentUser().id().id());
List<UserRole> userRoles = currentUser.getUserRoles();
for(UserRole ur : userRoles) {
if(ur.getRole().equals(RoleEnum.ROLE_EMPLOYEE)) {
return ok(..);
}
return ok(home.render());
}
据此,某些页面被拒绝角色 ROLE_EMPLOYEE。但是当注销时,最后一个 url 存储在 PLAY_SESSION cookie 中,并且在使用之前的意思角色的用户登录后,应用程序会自动重定向到错误的页面。有什么想法吗?