mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-24 09:45:11 +02:00
feat: Creating the first user
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { UserService } from '../user/user.service';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { User } from '../user/user.entity';
|
||||
|
||||
export interface AccessTokenPayload {
|
||||
sub: string;
|
||||
@@ -19,7 +20,9 @@ export class AuthService {
|
||||
): Promise<{
|
||||
token: string;
|
||||
}> {
|
||||
const user = await this.userService.findOneByName(name);
|
||||
let user = await this.userService.findOneByName(name);
|
||||
if (!user && (await this.userService.noPreviousAdmins()))
|
||||
user = await this.userService.create(name, password, true);
|
||||
|
||||
if (!(user && user.password === password)) {
|
||||
throw new UnauthorizedException();
|
||||
|
||||
Reference in New Issue
Block a user