Fix auth bug
This commit is contained in:
@@ -3,13 +3,13 @@ package be.naaturel.boardmateapi.common.models;
|
|||||||
public class Client {
|
public class Client {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String companyName;
|
||||||
private String username;
|
private String username;
|
||||||
private String key;
|
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.id = id;
|
||||||
this.name = name;
|
this.companyName = companyName;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,12 @@ public class Client {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getCompanyName() {
|
||||||
return name;
|
return companyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String setCompanyName(String companyName) {
|
||||||
|
return this.companyName = companyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class AuthController {
|
|||||||
|
|
||||||
JwtClaimsSet claims = JwtClaimsSet.builder()
|
JwtClaimsSet claims = JwtClaimsSet.builder()
|
||||||
.subject(user.getId())
|
.subject(user.getId())
|
||||||
.claim("name", user.getName())
|
.claim("name", user.getCompanyName())
|
||||||
.claim("username", user.getUsername())
|
.claim("username", user.getUsername())
|
||||||
.issuedAt(now)
|
.issuedAt(now)
|
||||||
.expiresAt(now.plusSeconds(3600*12))
|
.expiresAt(now.plusSeconds(3600*12))
|
||||||
@@ -57,7 +57,7 @@ public class AuthController {
|
|||||||
String token = jwtEncoder.encode(params).getTokenValue();
|
String token = jwtEncoder.encode(params).getTokenValue();
|
||||||
|
|
||||||
AuthResponseDto response = new AuthResponseDto();
|
AuthResponseDto response = new AuthResponseDto();
|
||||||
response.setName(user.getName());
|
response.setName(user.getCompanyName());
|
||||||
response.setUsername(user.getUsername());
|
response.setUsername(user.getUsername());
|
||||||
response.setClientId(user.getId());
|
response.setClientId(user.getId());
|
||||||
response.setAuthToken(token);
|
response.setAuthToken(token);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package be.naaturel.boardmateapi.repository.dtos;
|
package be.naaturel.boardmateapi.repository.dtos;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
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.Document;
|
||||||
import org.springframework.data.mongodb.core.mapping.Field;
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ public class ClientDto {
|
|||||||
private String clientId;
|
private String clientId;
|
||||||
|
|
||||||
@Field("serviceUsername")
|
@Field("serviceUsername")
|
||||||
|
@Indexed(unique = true)
|
||||||
private String serviceUsername;
|
private String serviceUsername;
|
||||||
|
|
||||||
@Field("serviceKey")
|
@Field("serviceKey")
|
||||||
|
|||||||
@@ -40,3 +40,4 @@ springdoc.api-docs.path=/v1/docs
|
|||||||
#=============DATABASE=============
|
#=============DATABASE=============
|
||||||
spring.mongodb.uri=${MONGODB_URI}
|
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