fix: prettier)

This commit is contained in:
2024-07-03 23:49:05 +03:00
parent a865789efa
commit 5e570a4f60
47 changed files with 5152 additions and 2835 deletions

View File

@@ -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);

View File

@@ -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;
// }
// }

View File

@@ -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();