mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00

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>
16 lines
427 B
TypeScript
16 lines
427 B
TypeScript
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;
|
|
}
|
|
}
|