use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class PersistentTokenRepositoryDefaultImpl method removeUserTokens.
@Override
public void removeUserTokens(String username) {
try {
User user = userService.getUserByEmail(username);
List<AuthToken> authTokens = authTokenService.findUserAuthTokens(user.getUuid());
for (AuthToken authToken : authTokens) {
authTokenService.deleteAuthToken(authToken.getUuid());
}
} catch (Throwable e) {
throw new RuntimeException("Failed to delete user auth tokens", e);
}
}
use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class PersistentTokenRepositoryDefaultImpl method getTokenForSeries.
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
try {
AuthToken authToken = authTokenService.getAuthTokenByUuid(seriesId);
User user = userService.getUserByUuid(authToken.getUserUuid());
return new PersistentRememberMeToken(user.getEmail(), authToken.getUuid(), authToken.getTokenValue(), new Date(authToken.getLastVerifiedAt()));
} catch (Throwable e) {
log.info("Persistent auth token wasn't found for seriesId " + seriesId);
return null;
}
}
use of org.summerb.users.api.dto.AuthToken in project summerb by skarpushin.
the class UserDetailsServiceDefaultImpl method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String userEmail) throws UsernameNotFoundException {
try {
User user = userService.getUserByEmail(userEmail);
List<String> permissions = permissionService.findUserPermissionsForSubject(SecurityConstants.DOMAIN, user.getUuid(), null);
AuthToken authToken = null;
UserDetailsImpl ret = new UserDetailsImpl(user, null, permissions, authToken);
return ret;
} catch (UserNotFoundException e) {
throw new UsernameNotFoundException("User not found", e);
} catch (FieldValidationException e) {
throw new UsernameNotFoundException("Email provided in invalid format", e);
} catch (Throwable t) {
throw new UsernameNotFoundException("Failed to get user by email", t);
}
}
Aggregations