UNPKG

@hz-9/a5-authn

Version:

Authentication module for the @hz-9/a5-* series of repositories.

53 lines 3.03 kB
"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.A5AuthnPwdController = void 0; const a5_crud_zod_1 = require("@hz-9/a5-crud-zod"); const common_1 = require("@nestjs/common"); const swagger_1 = require("@nestjs/swagger"); const const_1 = require("../../const"); const a5_authn_current_user_decorator_1 = require("../../decorators/a5-authn-current-user.decorator"); const dtos_1 = require("../../dtos"); const a5_authn_pwd_auth_guard_1 = require("./a5-authn-pwd.auth.guard"); const pwd_login_req_dto_1 = require("./dtos/pwd.login.req.dto"); let A5AuthnPwdController = class A5AuthnPwdController { constructor(service) { this.service = service; } async login(body, userPayload) { return this.service.getTokens(userPayload); } }; exports.A5AuthnPwdController = A5AuthnPwdController; __decorate([ (0, common_1.Post)('login'), (0, common_1.UseGuards)(a5_authn_pwd_auth_guard_1.A5AuthnPwdAuthGuard), (0, common_1.HttpCode)(common_1.HttpStatus.OK), (0, swagger_1.ApiOperation)({ summary: '用户名密码登录' }), (0, swagger_1.ApiResponse)({ status: 200, description: '登录成功', type: dtos_1.A5AuthnLoginResDto }), (0, swagger_1.ApiResponse)({ status: 400, description: '请求参数错误', type: a5_crud_zod_1.ErrorResDto }), (0, swagger_1.ApiResponse)({ status: 401, description: '邮箱或密码错误', type: a5_crud_zod_1.ErrorResDto }), __param(0, (0, common_1.Body)()), __param(1, (0, a5_authn_current_user_decorator_1.A5AuthnCurrentUser)()), __metadata("design:type", Function), __metadata("design:paramtypes", [pwd_login_req_dto_1.A5AuthnPwdLoginReqDto, Object]), __metadata("design:returntype", Promise) ], A5AuthnPwdController.prototype, "login", null); exports.A5AuthnPwdController = A5AuthnPwdController = __decorate([ (0, swagger_1.ApiTags)('Authentication'), (0, common_1.Controller)('auth/pwd'), __param(0, (0, common_1.Inject)(const_1.A5_AUTHN_SERVICE_TOKEN)), __metadata("design:paramtypes", [Object]) ], A5AuthnPwdController); //# sourceMappingURL=a5-authn-pwd.controller.js.map