forked from Archives/Athou_commafeed
Inject PostLoginActivities and refactor
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user