mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-15 03:07:55 +01:00
Saving users login to DB
This commit is contained in:
parent
50e6ff9928
commit
84fbe241d0
@ -18,14 +18,19 @@
|
||||
|
||||
package com.wisemapping.security;
|
||||
|
||||
import com.wisemapping.dao.UserManager;
|
||||
import com.wisemapping.model.UserLogin;
|
||||
import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;
|
||||
import org.acegisecurity.Authentication;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class CustomTokenBasedRememberMeServices extends
|
||||
TokenBasedRememberMeServices {
|
||||
private UserManager userManager;
|
||||
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
|
||||
{
|
||||
if(authentication!=null)
|
||||
@ -37,4 +42,24 @@ public class CustomTokenBasedRememberMeServices extends
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication successfulAuthentication) {
|
||||
final User user = (User)successfulAuthentication.getPrincipal();
|
||||
|
||||
final UserLogin userLogin = new UserLogin();
|
||||
final Calendar now = Calendar.getInstance();
|
||||
userLogin.setLoginDate(now);
|
||||
userLogin.setEmail(user.getUsername());
|
||||
userManager.auditLogin(userLogin);
|
||||
|
||||
super.loginSuccess(request, response, successfulAuthentication); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void setUserManager(UserManager userManager) {
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return userManager;
|
||||
}
|
||||
}
|
@ -123,6 +123,7 @@
|
||||
<bean id="rememberMeServices" class="com.wisemapping.security.CustomTokenBasedRememberMeServices">
|
||||
<property name="userDetailsService" ref="userDetailsService"/>
|
||||
<property name="key" value="changeThis"/>
|
||||
<property name="userManager" ref="userManager"/>
|
||||
</bean>
|
||||
|
||||
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
|
||||
|
Loading…
Reference in New Issue
Block a user