be
This commit is contained in:
5
backend/dist/users/dto/user-info-response.dto.d.ts
vendored
Normal file
5
backend/dist/users/dto/user-info-response.dto.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare class UserInfoResponseDto {
|
||||
id: number;
|
||||
name: string;
|
||||
email?: string;
|
||||
}
|
10
backend/dist/users/dto/user-info-response.dto.js
vendored
Normal file
10
backend/dist/users/dto/user-info-response.dto.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UserInfoResponseDto = void 0;
|
||||
class UserInfoResponseDto {
|
||||
id;
|
||||
name;
|
||||
email;
|
||||
}
|
||||
exports.UserInfoResponseDto = UserInfoResponseDto;
|
||||
//# sourceMappingURL=user-info-response.dto.js.map
|
1
backend/dist/users/dto/user-info-response.dto.js.map
vendored
Normal file
1
backend/dist/users/dto/user-info-response.dto.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"user-info-response.dto.js","sourceRoot":"","sources":["../../../src/users/dto/user-info-response.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAmB;IAC5B,EAAE,CAAS;IACX,IAAI,CAAS;IACb,KAAK,CAAU;CAClB;AAJD,kDAIC"}
|
3
backend/dist/users/users.controller.d.ts
vendored
3
backend/dist/users/users.controller.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
import { UsersService } from './users.service';
|
||||
import { ChangePasswordDto } from './dto/change-password.dto';
|
||||
import { SuccessResponseDto } from 'src/common/dto/sucees-response.dto';
|
||||
export declare class UsersController {
|
||||
private readonly userService;
|
||||
constructor(userService: UsersService);
|
||||
changePassword(req: any, dto: ChangePasswordDto): Promise<void>;
|
||||
changePassword(req: any, dto: ChangePasswordDto): Promise<SuccessResponseDto>;
|
||||
}
|
||||
|
7
backend/dist/users/users.controller.js
vendored
7
backend/dist/users/users.controller.js
vendored
@@ -16,18 +16,21 @@ exports.UsersController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const users_service_1 = require("./users.service");
|
||||
const change_password_dto_1 = require("./dto/change-password.dto");
|
||||
const jwt_auth_guard_1 = require("../auth/jwt-auth.guard");
|
||||
const sucees_response_dto_1 = require("../common/dto/sucees-response.dto");
|
||||
let UsersController = class UsersController {
|
||||
userService;
|
||||
constructor(userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
async changePassword(req, dto) {
|
||||
console.log("dd");
|
||||
return await this.userService.changePassword(2, dto);
|
||||
await this.userService.changePassword(req.user.userId, dto);
|
||||
return sucees_response_dto_1.SuccessResponseDto.ok();
|
||||
}
|
||||
};
|
||||
exports.UsersController = UsersController;
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||
(0, common_1.Patch)('password'),
|
||||
__param(0, (0, common_1.Request)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
|
2
backend/dist/users/users.controller.js.map
vendored
2
backend/dist/users/users.controller.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkE;AAClE,mDAA+C;AAC/C,mEAA8D;AAGvD,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IAAG,CAAC;IAGpD,AAAN,KAAK,CAAC,cAAc,CAAY,GAAG,EAAU,GAAsB;QAC/D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AARY,0CAAe;AAIlB;IADL,IAAA,cAAK,EAAC,UAAU,CAAC;IACI,WAAA,IAAA,gBAAO,GAAE,CAAA;IAAO,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,uCAAiB;;qDAGlE;0BAPQ,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAE0B,4BAAY;GAD7C,eAAe,CAQ3B"}
|
||||
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA6E;AAC7E,mDAA+C;AAC/C,mEAA8D;AAC9D,2DAAuD;AACvD,2EAAwE;AAGjE,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IAAG,CAAC;IAIpD,AAAN,KAAK,CAAC,cAAc,CAAY,GAAG,EAAU,GAAsB;QAC/D,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5D,OAAO,wCAAkB,CAAC,EAAE,EAAE,CAAC;IACnC,CAAC;CACJ,CAAA;AATY,0CAAe;AAKlB;IAFL,IAAA,kBAAS,EAAC,6BAAY,CAAC;IACvB,IAAA,cAAK,EAAC,UAAU,CAAC;IACI,WAAA,IAAA,gBAAO,GAAE,CAAA;IAAO,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,uCAAiB;;qDAGlE;0BARQ,eAAe;IAD3B,IAAA,mBAAU,EAAC,OAAO,CAAC;qCAE0B,4BAAY;GAD7C,eAAe,CAS3B"}
|
3
backend/dist/users/users.service.d.ts
vendored
3
backend/dist/users/users.service.d.ts
vendored
@@ -2,11 +2,14 @@ import { User } from './user.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CreateUserDto } from './dto/create-user.dto';
|
||||
import { ChangePasswordDto } from './dto/change-password.dto';
|
||||
import { UserInfoResponseDto } from './dto/user-info-response.dto';
|
||||
export declare class UsersService {
|
||||
private repo;
|
||||
constructor(repo: Repository<User>);
|
||||
findById(id: number): Promise<User | null>;
|
||||
findByName(name: string): Promise<User | null>;
|
||||
findByEmail(email: string): Promise<User | null>;
|
||||
create(dto: CreateUserDto): Promise<User>;
|
||||
changePassword(userId: number, dto: ChangePasswordDto): Promise<void>;
|
||||
findUserInfoByIdOrFail(id: number): Promise<UserInfoResponseDto>;
|
||||
}
|
||||
|
19
backend/dist/users/users.service.js
vendored
19
backend/dist/users/users.service.js
vendored
@@ -23,11 +23,14 @@ let UsersService = class UsersService {
|
||||
constructor(repo) {
|
||||
this.repo = repo;
|
||||
}
|
||||
async findById(id) {
|
||||
return await this.repo.findOne({ where: { id } });
|
||||
}
|
||||
async findByName(name) {
|
||||
return this.repo.findOne({ where: { name } });
|
||||
return await this.repo.findOne({ where: { name } });
|
||||
}
|
||||
async findByEmail(email) {
|
||||
return this.repo.findOne({ where: { email } });
|
||||
return await this.repo.findOne({ where: { email } });
|
||||
}
|
||||
async create(dto) {
|
||||
const existing = await this.findByName(dto.name);
|
||||
@@ -42,11 +45,21 @@ let UsersService = class UsersService {
|
||||
throw new common_1.NotFoundException("User not found");
|
||||
const passwordValid = await bcrypt.compare(dto.currentPassword, user.password);
|
||||
if (!passwordValid)
|
||||
throw new common_1.BadRequestException("Not matched password");
|
||||
throw new common_1.UnauthorizedException("Not matched password");
|
||||
const hashed = await bcrypt.hash(dto.newPassword, 10);
|
||||
user.password = hashed;
|
||||
await this.repo.save(user);
|
||||
}
|
||||
async findUserInfoByIdOrFail(id) {
|
||||
const user = await this.findById(id);
|
||||
if (!user)
|
||||
throw new common_1.NotFoundException("User not found");
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.UsersService = UsersService;
|
||||
exports.UsersService = UsersService = __decorate([
|
||||
|
2
backend/dist/users/users.service.js.map
vendored
2
backend/dist/users/users.service.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoF;AAC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