fix username
This commit is contained in:
@@ -41,12 +41,20 @@ public class JwtService {
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
Date expiry = new Date(now.getTime() + EXPIRATION_MS);
|
Date expiry = new Date(now.getTime() + EXPIRATION_MS);
|
||||||
|
|
||||||
|
String username="";
|
||||||
String email =azureJwt.getClaim("email");
|
String email = azureJwt.getClaim("email");
|
||||||
|
String username_claim = azureJwt.getClaim("username");
|
||||||
|
String unique_name = azureJwt.getClaim("unique_name");
|
||||||
|
|
||||||
|
if(username_claim == null){
|
||||||
|
username = unique_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( username.contains("@") ){
|
||||||
|
username = username.split("@")[0];
|
||||||
|
}
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setSubject(email)
|
.setSubject(username)
|
||||||
.setIssuedAt(new Date())
|
.setIssuedAt(new Date())
|
||||||
.setExpiration(expiry)
|
.setExpiration(expiry)
|
||||||
.signWith(getSignKey(), SignatureAlgorithm.HS512)
|
.signWith(getSignKey(), SignatureAlgorithm.HS512)
|
||||||
|
|||||||
Reference in New Issue
Block a user