1234567891011121314151617181920212223242526 |
- const UserRepository = require("../database").Repositories.Users;
- class Authorization {
- constructor() {
- }
- _parseToken(req, res, next) {
- const token = req.headers.token;
- if(!token)return next();
- // console.log("Token parsing : " + token);
- UserRepository.getUser(token).
- then((user) => {
- req.user = user;
- next();
- }).
- catch((err) => {
- res.sendStatus(400);
- });
- }
- getTokenParser() {
- return this._parseToken;
- }
- }
- module.exports = new Authorization();
|