Inject PostLoginActivities and refactor

This commit is contained in:
Sankaranarayanan Viswanathan
2014-10-08 22:18:16 -04:00
parent 67d7315003
commit 64b5d64709
3 changed files with 17 additions and 17 deletions

View File

@@ -34,9 +34,10 @@ public class UserService {
private final UserDAO userDAO;
private final UserSettingsDAO userSettingsDAO;
private final FeedSubscriptionService feedSubscriptionService;
private final PasswordEncryptionService encryptionService;
private final CommaFeedConfiguration config;
private final PostLoginActivities postLoginActivities;
/**
* try to log in with given credentials
@@ -103,11 +104,9 @@ public class UserService {
/**
* should triggers after successful login
*
* Note: Visibility changed to package private to enabled spying on this method
*/
void afterLogin(User user) {
new PostLoginActivities(userDAO, feedSubscriptionService, config).afterLogin(user);
private void afterLogin(User user) {
postLoginActivities.executeFor(user);
}
public User register(String name, String password, String email, Collection<Role> roles) {

View File

@@ -3,6 +3,7 @@ package com.commafeed.backend.service.internal;
import java.util.Date;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.RequiredArgsConstructor;
@@ -14,13 +15,14 @@ import com.commafeed.backend.model.User;
import com.commafeed.backend.service.FeedSubscriptionService;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
public class PostLoginActivities {
private final UserDAO userDAO;
private final FeedSubscriptionService feedSubscriptionService;
private final CommaFeedConfiguration config;
public void afterLogin(User user) {
public void executeFor(User user) {
Date lastLogin = user.getLastLogin();
Date now = new Date();