Skip to content

Commit

Permalink
获取当前用户信息出错时返回null
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix committed Mar 4, 2016
1 parent a6b1342 commit c534606
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/edu/scup/web/sys/util/ContextHolderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public static HttpSession getSession() {
}

public static SysUser getCurrentUser() {
Subject currentUser = SecurityUtils.getSubject();
return (SysUser) currentUser.getPrincipal();
try {
Subject currentUser = SecurityUtils.getSubject();
return (SysUser) currentUser.getPrincipal();
} catch (IllegalStateException e) {
return null;
}
}
}

0 comments on commit c534606

Please sign in to comment.