Public Access
Fixed tests
This commit is contained in:
1 parent
d63fbd4155
commit
0cd4d7328a
9 files changed
+26
-14
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package auth_service.configuration.security;
|
||||
|
||||
import auth_service.shared.security.UserPrincipal;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package auth_service.domain.user.controller;
|
||||
|
||||
import auth_service.configuration.security.UserPrincipal;
|
||||
import auth_service.shared.security.UserPrincipal;
|
||||
import auth_service.domain.user.controller.dto.request.UserSettingsRequest;
|
||||
import auth_service.domain.user.controller.dto.response.UserProfileResponse;
|
||||
import auth_service.domain.user.controller.mapper.ApiMapper;
|
||||
|
||||
@@ -61,15 +61,24 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean updateSettings(long userId, long steamId, UserSettings settings) {
|
||||
var entity = EntityMapper.toPersistence(userId, settings);
|
||||
// merge() acts as an upsert: it updates if the ID exists, or inserts if it doesn't.
|
||||
entityManager.merge(entity);
|
||||
|
||||
var userEntity = entityManager.find(UserEntity.class, userId);
|
||||
if (userEntity != null && userEntity.getSteamId() != steamId) {
|
||||
userEntity.setSteamId(steamId);
|
||||
return true;
|
||||
if (userEntity == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
var settingsEntity = userEntity.getSettings();
|
||||
if (settingsEntity == null) {
|
||||
settingsEntity = new UserSettingsEntity();
|
||||
settingsEntity.setUserId(userId);
|
||||
userEntity.setSettings(settingsEntity);
|
||||
}
|
||||
|
||||
settingsEntity.setLanguage(settings.getLanguage());
|
||||
settingsEntity.setTheme(settings.getTheme());
|
||||
|
||||
boolean steamIdChanged = userEntity.getSteamId() != steamId;
|
||||
userEntity.setSteamId(steamId);
|
||||
|
||||
return steamIdChanged;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class UserEntity {
|
||||
@Column(nullable = false)
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "steam_id", unique = true, nullable = false)
|
||||
@Column(name = "steam_id", unique = true)
|
||||
private Long steamId;
|
||||
|
||||
@Column(name = "registration_date", nullable = false)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package auth_service.configuration.security;
|
||||
package auth_service.shared.security;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Create the users table
|
||||
ALTER TABLE users
|
||||
ADD COLUMN steam_id BIGINT DEFAULT 0,
|
||||
ADD COLUMN steam_id BIGINT,
|
||||
ADD COLUMN registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN last_login_date TIMESTAMP;
|
||||
|
||||
|
||||
Reference in new issue
Block a user