Fix auth bug

This commit is contained in:
2026-01-01 16:54:04 +01:00
parent 458a3e0e6c
commit a0e974d511
4 changed files with 15 additions and 8 deletions

View File

@@ -3,13 +3,13 @@ package be.naaturel.boardmateapi.common.models;
public class Client {
private String id;
private String name;
private String companyName;
private String username;
private String key;
public Client(String id, String name, String username, String key){
public Client(String id, String companyName, String username, String key){
this.id = id;
this.name = name;
this.companyName = companyName;
this.username = username;
this.key = key;
}
@@ -22,8 +22,12 @@ public class Client {
this.id = id;
}
public String getName() {
return name;
public String getCompanyName() {
return companyName;
}
public String setCompanyName(String companyName) {
return this.companyName = companyName;
}
public void setUsername(String username) {

View File

@@ -42,7 +42,7 @@ public class AuthController {
JwtClaimsSet claims = JwtClaimsSet.builder()
.subject(user.getId())
.claim("name", user.getName())
.claim("name", user.getCompanyName())
.claim("username", user.getUsername())
.issuedAt(now)
.expiresAt(now.plusSeconds(3600*12))
@@ -57,7 +57,7 @@ public class AuthController {
String token = jwtEncoder.encode(params).getTokenValue();
AuthResponseDto response = new AuthResponseDto();
response.setName(user.getName());
response.setName(user.getCompanyName());
response.setUsername(user.getUsername());
response.setClientId(user.getId());
response.setAuthToken(token);

View File

@@ -1,6 +1,7 @@
package be.naaturel.boardmateapi.repository.dtos;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@@ -16,6 +17,7 @@ public class ClientDto {
private String clientId;
@Field("serviceUsername")
@Indexed(unique = true)
private String serviceUsername;
@Field("serviceKey")

View File

@@ -40,3 +40,4 @@ springdoc.api-docs.path=/v1/docs
#=============DATABASE=============
spring.mongodb.uri=${MONGODB_URI}
spring.mongodb.database=${DATABASE_NAME}
spring.data.mongodb.auto-index-creation=true