mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-24 09:45:11 +02:00
feat: Editing, creating and deleting server accounts, user.controller improvements
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { UserService } from '../user/user.service';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { User } from '../user/user.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
|
||||
export interface AccessTokenPayload {
|
||||
sub: string;
|
||||
@@ -10,7 +10,7 @@ export interface AccessTokenPayload {
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private userService: UsersService,
|
||||
private jwtService: JwtService,
|
||||
) {}
|
||||
|
||||
@@ -23,7 +23,11 @@ export class AuthService {
|
||||
}> {
|
||||
let user = await this.userService.findOneByName(name);
|
||||
if (!user && (await this.userService.noPreviousAdmins()))
|
||||
user = await this.userService.create(name, password, true);
|
||||
user = await this.userService.create({
|
||||
name,
|
||||
password,
|
||||
isAdmin: true,
|
||||
});
|
||||
|
||||
if (!(user && user.password === password)) {
|
||||
throw new UnauthorizedException();
|
||||
|
||||
Reference in New Issue
Block a user