Fix auth bug
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -39,4 +39,5 @@ springdoc.api-docs.path=/v1/docs
|
||||
|
||||
#=============DATABASE=============
|
||||
spring.mongodb.uri=${MONGODB_URI}
|
||||
spring.mongodb.database=${DATABASE_NAME}
|
||||
spring.mongodb.database=${DATABASE_NAME}
|
||||
spring.data.mongodb.auto-index-creation=true
|
||||
Reference in New Issue
Block a user