Denied access to login & register while logged in. Fixed regular user auth for requiring admin.
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { UserEntity } from 'src/users/entities/users.entity';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { AuthRefreshService } from './auth.refresh.service';
|
||||
import { AuthAccessService } from './auth.access.service';
|
||||
import { UUID } from 'crypto';
|
||||
import { AuthenticationDto } from './dto/authentication.dto';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@ -15,10 +17,14 @@ export class AuthService {
|
||||
|
||||
|
||||
async login(
|
||||
user: UserEntity,
|
||||
withRefresh: boolean
|
||||
): Promise<AuthenticationDto> {
|
||||
if (withRefresh) {
|
||||
loginDetails: LoginDto
|
||||
): Promise<AuthenticationDto | null> {
|
||||
const user = await this.users.findOne(loginDetails);
|
||||
if (!user) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
if (loginDetails.remember_me) {
|
||||
return this.renew(user);
|
||||
}
|
||||
|
||||
@ -47,7 +53,7 @@ export class AuthService {
|
||||
username: string,
|
||||
password: string,
|
||||
): Promise<UserEntity | null> {
|
||||
return await this.users.findOne({ username, password });
|
||||
return await this.users.findOne({ user_login: username, password, remember_me: false });
|
||||
}
|
||||
|
||||
async verify(
|
||||
|
Reference in New Issue
Block a user