private OnlineSectioningLog.Entity currentUser(SessionContext context) {
   UserContext user = context.getUser();
   UniTimePrincipal principal = (UniTimePrincipal) context.getAttribute("user");
   if (user != null) {
     return OnlineSectioningLog.Entity.newBuilder()
         .setExternalId(user.getExternalUserId())
         .setName(user.getName() == null ? user.getUsername() : user.getName())
         .setType(
             context.hasPermission(Right.StudentSchedulingAdvisor)
                 ? OnlineSectioningLog.Entity.EntityType.MANAGER
                 : OnlineSectioningLog.Entity.EntityType.STUDENT)
         .build();
   } else if (principal != null) {
     return OnlineSectioningLog.Entity.newBuilder()
         .setExternalId(principal.getExternalId())
         .setName(principal.getName())
         .setType(OnlineSectioningLog.Entity.EntityType.STUDENT)
         .build();
   } else {
     return null;
   }
 }
    @Override
    public boolean check(UserContext user, Session source) {
      if (user instanceof UserContext.Chameleon) return false;

      return User.findByUserName(user.getUsername()) != null;
    }