Fix keygroup in authentication

This commit is contained in:
2024-09-23 19:02:37 +02:00
parent 93832a5e60
commit b8e03337ee
2 changed files with 11 additions and 6 deletions

View File

@@ -132,7 +132,7 @@ public class AuthService {
StbAuthToken stbAuthToken = refreshTokenService.createRefreshTokenIfNotExists(
username,
password,
String.valueOf(userData.getUser().getKeyGroup()),
userData.getUser().getKeyGroup(),
primaryProfileDb,
stbDevices.getId()
);

View File

@@ -97,7 +97,7 @@ public class RefreshTokenService {
StbAuthToken newRefreshToken = this.createRefreshTokenIfNotExists(
user.getUserName(),
user.getPassword(),
String.valueOf(user.getKeyGroup()),
user.getKeyGroup(),
profileDb,
stbAuthToken.getDeviceId());
@@ -116,7 +116,7 @@ public class RefreshTokenService {
}
}
public StbAuthToken createRefreshTokenIfNotExists(String username, String password, String keyGroup, String profileDb, Long deviceId) throws Exception {
public StbAuthToken createRefreshTokenIfNotExists(String username, String password, Integer keyGroup, String profileDb, Long deviceId) throws Exception {
LocalDateTime expiryDate = LocalDateTime.now().plusDays(settingsModel.getRefreshTokenExpireDays());
if (deviceId == null)
@@ -144,10 +144,15 @@ public class RefreshTokenService {
}
private UsernamePasswordAuthenticationToken createAuthenticationToken(String username, String password, String keyGroup, long deviceId) throws PrimaryDatabaseNotPresentException {
private UsernamePasswordAuthenticationToken createAuthenticationToken(String username, String password, Integer keyGroup, long deviceId) throws PrimaryDatabaseNotPresentException {
ImmutableList<SimpleGrantedAuthority> simpleGrantedAuthorities = null;
if (keyGroup != null) {
simpleGrantedAuthorities = ImmutableList.of(new SimpleGrantedAuthority(String.valueOf(keyGroup)));
}
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(username, password,
ImmutableList.of(new SimpleGrantedAuthority(keyGroup)));
new UsernamePasswordAuthenticationToken(username, password, simpleGrantedAuthorities);
UserDTO user = UtilityUser.getCurrentUser(multiDBTransactionManager, username);