@Check("login") public static void index() { User curUser = User.find("byName", Secure.Security.connected()).first(); if (curUser.type == UserType.ADMINISTRATOR) { redirect("/admin/crud"); } else if (curUser.type == UserType.STUDENT) { Student.index(); } else { Teacher.index(); } }
public void beforeRoleCheck() { // Note that if you provide your own implementation of Secure's Security class you would refer // to that instead if (!Secure.Security.isConnected()) { try { if (!session.contains("username")) { flash.put("url", "GET".equals(request.method) ? request.url : "/"); Secure.login(); } } catch (Throwable t) { // handle this in an app-specific way } } }
public RoleHolder getRoleHolder() { String userName = Secure.Security.connected(); return User.getByUserName(userName); }