Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Aug 20, 2024
1 parent 9267fc2 commit f445238
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,10 @@ public boolean isUserInRole(String role) {
@Override
public Principal getUserPrincipal() {
if (principal == null) {
// try {
// principal = runtime.getSecurityProvider().getUser(this);
// } catch (ServletException e) {
// throw new RuntimeException(e);
// }
Object o = getSession().getAttribute("principal");
if (o != null) {
principal = (LoginAccount) o;
}
}
return principal;
}
Expand Down Expand Up @@ -395,7 +394,7 @@ public boolean authenticate(HttpServletResponse response) {
public void login(String username, String password) throws ServletException {
SecurityAccount securityAccount = runtime.getSecurityProvider().login(username, password);
if (securityAccount != null) {
principal = new LoginAccount(securityAccount.getUsername(), securityAccount.getPassword(), securityAccount.getRoles());
setLoginAccount(new LoginAccount(securityAccount.getUsername(), securityAccount.getPassword(), securityAccount.getRoles()));
}
}

Expand Down Expand Up @@ -847,6 +846,7 @@ public void setAsyncSupported(boolean supported) {
@Override
public void setLoginAccount(LoginAccount loginAccount) {
this.principal = loginAccount;
getSession().setAttribute("principal", loginAccount);
}

@Override
Expand Down

0 comments on commit f445238

Please sign in to comment.