auth fix
This commit is contained in:
parent
b27fee6ece
commit
3256b0a4a7
@ -305,22 +305,22 @@ export class AuthService {
|
|||||||
// throw new BadRequestException("Invalid username or password")
|
// throw new BadRequestException("Invalid username or password")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (access_token && refresh_token && userSession.length > 0) {
|
// if (access_token && refresh_token && userSession.length > 0) {
|
||||||
|
|
||||||
const getSub: any = jwt.decode(refresh_token, { complete: true })
|
// const getSub: any = jwt.decode(refresh_token, { complete: true })
|
||||||
|
|
||||||
const user: any = await this.getUserDetailsById(getSub?.payload.sub)
|
// const user: any = await this.getUserDetailsById(getSub?.payload.sub)
|
||||||
|
|
||||||
if (user.email !== username) {
|
// if (user.email !== username) {
|
||||||
throw new UnauthorizedException("Authentication failed")
|
// throw new UnauthorizedException("Authentication failed")
|
||||||
}
|
// }
|
||||||
|
|
||||||
let tokens = await this.getTokenFromRefreshToken(req);
|
// let tokens = await this.getTokenFromRefreshToken(req);
|
||||||
const decoded = jwt.decode(access_token, { complete: true });
|
// const decoded = jwt.decode(access_token, { complete: true });
|
||||||
const email: any = (decoded && typeof decoded === 'object') ? (decoded as any).payload?.email : undefined;
|
// const email: any = (decoded && typeof decoded === 'object') ? (decoded as any).payload?.email : undefined;
|
||||||
return { ...tokens, email, ApplicationName: ROLE }
|
// return { ...tokens, email, ApplicationName: ROLE }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
const response = await axios.post(this.TOKEN_URL, params, {
|
const response = await axios.post(this.TOKEN_URL, params, {
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
|
|||||||
@ -25,7 +25,12 @@ export class JwtAuthGuard implements CanActivate {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(request.cookies);
|
||||||
|
|
||||||
|
console.log(token);
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
console.log("token not found")
|
||||||
throw new UnauthorizedException('Authentication failed');
|
throw new UnauthorizedException('Authentication failed');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -20,7 +20,12 @@ async function bootstrap() {
|
|||||||
'http://localhost:5173',
|
'http://localhost:5173',
|
||||||
'https://policy.alphaomegainfosys.com',
|
'https://policy.alphaomegainfosys.com',
|
||||||
'https://sp.alphaomegainfosys.com',
|
'https://sp.alphaomegainfosys.com',
|
||||||
'https://client.alphaomegainfosys.com'
|
'https://policy-2.alphaomegainfosys.com',
|
||||||
|
'https://client-2.alphaomegainfosys.com',
|
||||||
|
'https://sp-2.alphaomegainfosys.com',
|
||||||
|
'https://policy-1.alphaomegainfosys.com',
|
||||||
|
'https://client-1.alphaomegainfosys.com',
|
||||||
|
'https://sp-1.alphaomegainfosys.com',
|
||||||
],
|
],
|
||||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||||
preflightContinue: false,
|
preflightContinue: false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user