mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
Refactored UserREST login to populate session itself
This commit is contained in:
@@ -21,6 +21,7 @@ import com.commafeed.backend.model.User;
|
||||
import com.commafeed.backend.model.UserRole;
|
||||
import com.commafeed.backend.model.UserRole.Role;
|
||||
import com.commafeed.backend.service.internal.PostLoginActivities;
|
||||
import com.commafeed.frontend.resource.UserREST;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@@ -28,8 +29,6 @@ import com.google.common.base.Preconditions;
|
||||
@Singleton
|
||||
public class UserService {
|
||||
|
||||
private static final String SESSION_KEY_USER = "user";
|
||||
|
||||
private final FeedCategoryDAO feedCategoryDAO;
|
||||
private final UserDAO userDAO;
|
||||
private final UserSettingsDAO userSettingsDAO;
|
||||
@@ -67,7 +66,7 @@ public class UserService {
|
||||
public Optional<User> login(String nameOrEmail, String password, HttpSession sessionToFill) {
|
||||
Optional<User> user = login(nameOrEmail, password);
|
||||
if (user.isPresent()) {
|
||||
sessionToFill.setAttribute(SESSION_KEY_USER, user.get());
|
||||
sessionToFill.setAttribute(UserREST.SESSION_KEY_USER, user.get());
|
||||
}
|
||||
return user;
|
||||
}
|
||||
@@ -77,7 +76,7 @@ public class UserService {
|
||||
*/
|
||||
public Optional<User> login(HttpSession session) {
|
||||
if (session != null) {
|
||||
User user = (User) session.getAttribute(SESSION_KEY_USER);
|
||||
User user = (User) session.getAttribute(UserREST.SESSION_KEY_USER);
|
||||
if (user != null) {
|
||||
afterLogin(user);
|
||||
return Optional.of(user);
|
||||
|
||||
Reference in New Issue
Block a user