mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-15 21:19:42 +03:00
fix: prettier)
This commit is contained in:
@@ -30,7 +30,6 @@ export class AuthController {
|
||||
@ApiOperation({
|
||||
description: "Register into system",
|
||||
})
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Post("register")
|
||||
register(@Body() signInDto: LoginDto) {
|
||||
return this.authService.register(signInDto.username, signInDto.password);
|
||||
|
||||
@@ -2,30 +2,3 @@ import { Injectable } from "@nestjs/common";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
@Injectable()
|
||||
export class JwtGuard extends AuthGuard("jwt") {}
|
||||
// export class AuthGuard implements CanActivate {
|
||||
// constructor(private jwtService: JwtService) {}
|
||||
|
||||
// async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
// const request = context.switchToHttp().getRequest();
|
||||
// const token = this.extractTokenFromHeader(request);
|
||||
// if (!token) {
|
||||
// throw new UnauthorizedException();
|
||||
// }
|
||||
// try {
|
||||
// const payload = await this.jwtService.verifyAsync(token, {
|
||||
// secret: config.auth.jwt_secret,
|
||||
// });
|
||||
|
||||
// request["user"] = payload;
|
||||
// } catch {
|
||||
// throw new UnauthorizedException();
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// private extractTokenFromHeader(request: Request): string | undefined {
|
||||
// const [type, token] = request.headers.authorization.split(" ") ?? [];
|
||||
// return type === "Bearer" ? token : undefined;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable, Logger, UnauthorizedException } from "@nestjs/common";
|
||||
import { ImATeapotException, Injectable, Logger, UnauthorizedException } from "@nestjs/common";
|
||||
import { JwtService } from "@nestjs/jwt";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import * as bcrypt from "bcrypt";
|
||||
import * as bcrypt from "bcryptjs";
|
||||
import { WebUser } from "libs/database/web_user.entity";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
@@ -35,6 +35,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async register(username: string, password: string): Promise<{ access_token: string }> {
|
||||
if (1) throw new ImATeapotException();
|
||||
const user = await this.userRepository.findOne({ where: { login: username } });
|
||||
if (user) throw new UnauthorizedException("User already exists");
|
||||
const salt = await bcrypt.genSalt();
|
||||
|
||||
Reference in New Issue
Block a user