mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-25 04:10:05 +00:00
REFACTOR: Project Pattern and AuthClient (DUC)
This commit is contained in:
@@ -2,29 +2,22 @@ import { Request, Response, NextFunction } from 'express';
|
||||
import axios from 'axios';
|
||||
import { NestMiddleware } from '@nestjs/common';
|
||||
|
||||
export class LoggerMiddleware implements NestMiddleware{
|
||||
|
||||
|
||||
use = async (
|
||||
request: Request,
|
||||
response: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
|
||||
try {
|
||||
const verify_response = await axios.post(
|
||||
`${process.env.DEV_URL}/user/verify`,
|
||||
{ "token":request.get('Authorization')}
|
||||
).then(response =>{
|
||||
if(response.data.message == "Success"){
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
} catch (error) {
|
||||
response.status(401).send({ message: 'Authentication Failed!' });
|
||||
}
|
||||
};
|
||||
export class LoggerMiddleware implements NestMiddleware {
|
||||
use = async (request: Request, response: Response, next: NextFunction) => {
|
||||
try {
|
||||
const verify_response = await axios
|
||||
.post(`${process.env.DEV_URL}/user/verify`, {
|
||||
token: request.get('Authorization'),
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.data.message == 'Success') {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
console.log(verify_response);
|
||||
} catch (error) {
|
||||
response.status(401).send({ message: 'Authentication Failed!' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user