FIX: removed state

This commit is contained in:
Gabriel Rosa
2023-12-07 19:39:09 -03:00
parent 98759b1cf5
commit fd0d68b149
2 changed files with 15 additions and 12 deletions
+8 -7
View File
@@ -371,13 +371,14 @@ export class AuthController {
const { authInfo } = req; const { authInfo } = req;
const url = this.frontendRedirectUrl; const url = this.frontendRedirectUrl;
let email, token, refreshToken, error_title, error_description; let email, token, refreshToken, error_title, error_description;
let language: 'pt-br' | 'en-us' = 'pt-br'; const language: 'pt-br' | 'en-us' = 'pt-br';
// let stateObject;
const stateObject = jwt.verify( // try {
state as string, // stateObject = jwt.verify(state as string, process.env.JWT_PRIVATE_KEY);
process.env.JWT_PRIVATE_KEY, // } catch (error) {
); // console.log('error', error);
if (typeof stateObject != 'string') language = stateObject.language; // }
// if (typeof stateObject != 'string') language = stateObject.language;
if (error || !authInfo) { if (error || !authInfo) {
this.logger.error(error); this.logger.error(error);
@@ -37,9 +37,11 @@ export class MagaluIdStrategy extends PassportStrategy(
super(options, verify); super(options, verify);
} }
authenticate(req: Request, options: Record<string, any>) { // authenticate(req: Request, options: Record<string, any>) {
const language = req.headers['dadosfera-lang'] || req.query.language; // const language =
options.state = jwt.sign({ language }, process.env.JWT_PRIVATE_KEY); // req.headers['dadosfera-lang'] || req.query.language || 'pt-br';
super.authenticate(req, options); // // options.state = jwt.sign({ language }, process.env.JWT_PRIVATE_KEY);
} // super.authenticate(req, options);
// console.log('authenticate', JSON.stringify(options));
// }
} }