Skip to content

Commit

Permalink
fix: user service
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Jun 11, 2024
1 parent d536a6b commit 7faaa27
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/fr/recia/collabsoft/service/db/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ public class UserService {
@Autowired
private SoffitHolder soffitHolder;

private boolean isSubOk() {
final boolean isOk = soffitHolder.getSub() != null && !soffitHolder.getSub().startsWith("guest");
if (!isOk) log.debug("User is guest : sub \"{}\"", soffitHolder.getSub());

return isOk;
}

public User getCurrentUser() {
if (!isSubOk()) return null;
final User user = userRepository.findOne(
QUser.user.casUid.eq(soffitHolder.getSub())
).orElse(null);
Expand All @@ -54,11 +62,7 @@ public User getUser(Long userId) {
}

public User createUser() {
if (soffitHolder.getSub() == null || soffitHolder.getSub().startsWith("guest")) {
log.debug("Unable to create user with sub \"{}\"", soffitHolder.getSub());

return null;
}
if (!isSubOk()) return null;
if (getCurrentUser() != null) {
log.debug("User with sub \"{}\" already exist", soffitHolder.getSub());

Expand Down

0 comments on commit 7faaa27

Please sign in to comment.