Browse Source

change bid substring to colon delimiter

main^2
DashEightMate 5 months ago
parent
commit
10621222af
  1. 16
      src/services/UserService.ts

16
src/services/UserService.ts

@ -36,11 +36,15 @@ export class UserService {
}
public login(res: LoginResponse): void {
const bid = res.jwt.substring(192);
Cookies.set('jwt', res.jwt.substring(0, 192), { expires: 365 });
this.setClaims(res.jwt.substring(0, 192));
if (bid.length > 0 && localStorage.getItem('bid') === null) {
localStorage.setItem('bid', bid);
const jwt_split = res.jwt.split(':');
Cookies.set('jwt', jwt_split[0], { expires: 365 });
this.setClaims(jwt_split[0]);
if (
jwt_split.length > 1 &&
jwt_split[1].length > 0 &&
localStorage.getItem('bid') === null
) {
localStorage.setItem('bid', jwt_split[1]);
}
console.log('logged in');
}
@ -72,7 +76,7 @@ export class UserService {
const bid = localStorage.getItem('bid');
if (jwt) {
if (bid) {
return jwt + bid;
return `${jwt}:${bid}`;
}
return jwt;
}

Loading…
Cancel
Save