Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async use (@Req() req: Req, @EndpointInfo() endpoint: EndpointInfo) {
- // const options = endpoint.get(FirebaseAuth) || {};
- const token: string = this.getToken(req);
- try {
- await this.app.auth().verifyIdToken(token)
- } catch (e) {
- $log.error(e);
- throw(new Unauthorized('Decoding token failed'));
- }
- }
- private getToken(req: Req): string {
- if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
- return req.headers.authorization.split(' ')[1];
- }
- $log.error('Token not found');
- throw(new Unauthorized('Token not found'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement