|
|
|
"use strict";
|
|
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
|
|
};
|
|
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
|
|
};
|
|
|
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.AuthController = void 0;
|
|
|
|
const openapi = require("@nestjs/swagger");
|
|
|
|
const common_1 = require("@nestjs/common");
|
|
|
|
const auth_service_1 = require("./auth.service");
|
|
|
|
const create_user_dto_1 = require("../users/dto/create-user.dto");
|
|
|
|
const login_user_dto_1 = require("./dto/login-user.dto");
|
|
|
|
const login_response_dto_1 = require("./dto/login-response.dto");
|
|
|
|
const users_service_1 = require("../users/users.service");
|
|
|
|
const jwt_auth_guard_1 = require("./jwt-auth.guard");
|
|
|
|
const user_info_response_dto_1 = require("../users/dto/user-info-response.dto");
|
|
|
|
const swagger_1 = require("@nestjs/swagger");
|
|
|
|
const create_user_response_dto_1 = require("../users/dto/create-user-response.dto");
|
|
|
|
const check_availability_response_dto_1 = require("./dto/check-availability-response.dto");
|
|
|
|
const check_name_dto_1 = require("./dto/check-name.dto");
|
|
|
|
const check_email_dto_1 = require("./dto/check-email.dto");
|
|
|
|
let AuthController = class AuthController {
|
|
|
|
authService;
|
|
|
|
userService;
|
|
|
|
constructor(authService, userService) {
|
|
|
|
this.authService = authService;
|
|
|
|
this.userService = userService;
|
|
|
|
}
|
|
|
|
async signup(dto) {
|
|
|
|
const user = await this.authService.signup(dto);
|
|
|
|
return {
|
|
|
|
name: user.name,
|
|
|
|
email: user.email,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
async login(dto) {
|
|
|
|
return await this.authService.login(dto);
|
|
|
|
}
|
|
|
|
async getMe(req) {
|
|
|
|
return await this.userService.findUserWithProfileByIdOrFail(req.user.userId);
|
|
|
|
}
|
|
|
|
async checkName(dto) {
|
|
|
|
const available = await this.authService.isNameAvailable(dto.name);
|
|
|
|
return { available };
|
|
|
|
}
|
|
|
|
async checkEmail(dto) {
|
|
|
|
const available = await this.authService.isEmailAvailabe(dto.email);
|
|
|
|
return { available };
|
|
|
|
}
|
|
|
|
async deleteMe(req) {
|
|
|
|
await this.userService.softDelete(req.user.userId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
exports.AuthController = AuthController;
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Post)('signup'),
|
|
|
|
(0, common_1.HttpCode)(200),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '회원가입' }),
|
|
|
|
(0, swagger_1.ApiOkResponse)({ description: '성공', type: create_user_response_dto_1.CreateUserResponse }),
|
|
|
|
openapi.ApiResponse({ status: 200, type: require("../users/dto/create-user-response.dto").CreateUserResponse }),
|
|
|
|
__param(0, (0, common_1.Body)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [create_user_dto_1.CreateUserDto]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "signup", null);
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Post)('login'),
|
|
|
|
(0, common_1.HttpCode)(200),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '로그인' }),
|
|
|
|
(0, swagger_1.ApiOkResponse)({ description: '성공', type: login_response_dto_1.LoginResponseDto }),
|
|
|
|
openapi.ApiResponse({ status: 200, type: require("./dto/login-response.dto").LoginResponseDto }),
|
|
|
|
__param(0, (0, common_1.Body)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [login_user_dto_1.LoginUserDto]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "login", null);
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Get)('me'),
|
|
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '정보 확인' }),
|
|
|
|
(0, swagger_1.ApiOkResponse)({ description: '성공', type: user_info_response_dto_1.UserInfoResponseDto }),
|
|
|
|
openapi.ApiResponse({ status: 200, type: require("../users/dto/user-info-response.dto").UserInfoResponseDto }),
|
|
|
|
__param(0, (0, common_1.Request)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [Object]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "getMe", null);
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Post)('check-name'),
|
|
|
|
(0, common_1.HttpCode)(200),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '사용자 이름 중복 확인' }),
|
|
|
|
(0, swagger_1.ApiOkResponse)({ description: '성공', type: check_availability_response_dto_1.CheckAvailabilityResponseDto }),
|
|
|
|
openapi.ApiResponse({ status: 200, type: require("./dto/check-availability-response.dto").CheckAvailabilityResponseDto }),
|
|
|
|
__param(0, (0, common_1.Body)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [check_name_dto_1.CheckNameDto]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "checkName", null);
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Post)('check-email'),
|
|
|
|
(0, common_1.HttpCode)(200),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '사용자 이메일 중복 확인' }),
|
|
|
|
(0, swagger_1.ApiOkResponse)({ description: '성공', type: check_availability_response_dto_1.CheckAvailabilityResponseDto }),
|
|
|
|
openapi.ApiResponse({ status: 200, type: require("./dto/check-availability-response.dto").CheckAvailabilityResponseDto }),
|
|
|
|
__param(0, (0, common_1.Body)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [check_email_dto_1.CheckEmailDto]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "checkEmail", null);
|
|
|
|
__decorate([
|
|
|
|
(0, common_1.Delete)('me'),
|
|
|
|
(0, common_1.HttpCode)(204),
|
|
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
|
|
(0, swagger_1.ApiOperation)({ summary: '회원 탈퇴' }),
|
|
|
|
(0, swagger_1.ApiNoContentResponse)({ description: '탈퇴 완료' }),
|
|
|
|
(0, swagger_1.ApiNotFoundResponse)({ description: '존재하지 않는 사용자' }),
|
|
|
|
openapi.ApiResponse({ status: 204 }),
|
|
|
|
__param(0, (0, common_1.Request)()),
|
|
|
|
__metadata("design:type", Function),
|
|
|
|
__metadata("design:paramtypes", [Object]),
|
|
|
|
__metadata("design:returntype", Promise)
|
|
|
|
], AuthController.prototype, "deleteMe", null);
|
|
|
|
exports.AuthController = AuthController = __decorate([
|
|
|
|
(0, swagger_1.ApiTags)('인증'),
|
|
|
|
(0, common_1.Controller)('auth'),
|
|
|
|
__metadata("design:paramtypes", [auth_service_1.AuthService,
|
|
|
|
users_service_1.UsersService])
|
|
|
|
], AuthController);
|
|
|
|
//# sourceMappingURL=auth.controller.js.map
|