spyhunter99 commented on code in PR #460:
URL: https://github.com/apache/jspwiki/pull/460#discussion_r2582920864


##########
jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java:
##########
@@ -201,8 +206,34 @@ public boolean login( final HttpServletRequest request ) 
throws WikiSecurityExce
                 fireEvent( WikiSecurityEvent.LOGIN_ANONYMOUS, 
getLoginPrincipal( principals ), session, request );
                 return true;
             }
+        } else {
+            //attempt to get the user profile
+           
+            try {
+                UserManager mgr = m_engine.getManager(UserManager.class);
+                UserProfile profile = 
mgr.getUserDatabase().findByLoginName(session.getLoginPrincipal().getName());
+                if (request.getSession().getAttribute("LOGINTIMESTAMPSET") == 
null) {
+                    request.getSession().setAttribute("LOGINTIMESTAMPSET", 
"true");
+                    String lastLoginAt = (String) 
profile.getAttributes().get("CURRENT_LOGIN_TIMESTAMP");
+                    String oldIp = (String) 
profile.getAttributes().get("CURRENT_LOGIN_IP");
+                    if (lastLoginAt != null) {
+                        
profile.getAttributes().put("PREVIOUS_LOGIN_TIMESTAMP", lastLoginAt);
+                    }
+                    if (oldIp != null) {
+                        profile.getAttributes().put("PREVIOUS_LOGIN_IP", 
oldIp);
+                    }
+                    profile.getAttributes().put("CURRENT_LOGIN_IP", 
request.getRemoteAddr());
+                    profile.getAttributes().put("CURRENT_LOGIN_TIMESTAMP", new 
Date().toString());

Review Comment:
   and maybe make some constants values for those new attributes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to