mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
auth: adds token-auth to public api
adds auth service adds auth module adds token-auth strategy adds token-auth to all public api calls Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
9a65a9bd29
commit
8d89614a4d
11 changed files with 174 additions and 18 deletions
16
src/auth/auth.service.ts
Normal file
16
src/auth/auth.service.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { User } from '../users/user.entity';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(private usersService: UsersService) {}
|
||||
|
||||
async validateToken(token: string): Promise<User> {
|
||||
const user = await this.usersService.getUserByAuthToken(token);
|
||||
if (user) {
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue