@bitwild/rockets-auth
Version:
Rockets Auth - Complete authentication and authorization solution for NestJS with JWT, OAuth, OTP, role-based access control, and more
73 lines • 3.55 kB
JavaScript
;
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.AuthPasswordController = void 0;
const nestjs_auth_local_1 = require("@concepta/nestjs-auth-local");
const nestjs_authentication_1 = require("@concepta/nestjs-authentication");
const common_1 = require("@nestjs/common");
const throttler_1 = require("@nestjs/throttler");
const swagger_1 = require("@nestjs/swagger");
const rockets_auth_jwt_response_dto_1 = require("../dto/rockets-auth-jwt-response.dto");
const rockets_auth_login_dto_1 = require("../dto/rockets-auth-login.dto");
let AuthPasswordController = class AuthPasswordController {
constructor(issueTokenService) {
this.issueTokenService = issueTokenService;
}
async login(user) {
return this.issueTokenService.responsePayload(user.id);
}
};
exports.AuthPasswordController = AuthPasswordController;
__decorate([
(0, swagger_1.ApiOperation)({
summary: 'Authenticate with username/email and password',
description: 'Validates credentials and returns authentication tokens on success',
}),
(0, swagger_1.ApiBody)({
type: rockets_auth_login_dto_1.RocketsAuthLoginDto,
description: 'User credentials',
examples: {
standard: {
value: {
username: 'user@example.com',
password: 'StrongP@ssw0rd',
},
summary: 'Standard login request',
},
},
}),
(0, swagger_1.ApiOkResponse)({
type: rockets_auth_jwt_response_dto_1.RocketsAuthJwtResponseDto,
description: 'Authentication successful, tokens provided',
}),
(0, swagger_1.ApiUnauthorizedResponse)({
description: 'Invalid credentials or inactive account',
}),
(0, common_1.HttpCode)(200),
(0, throttler_1.Throttle)({ default: { limit: 5, ttl: 60000 } }),
(0, common_1.Post)(),
__param(0, (0, nestjs_authentication_1.AuthUser)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthPasswordController.prototype, "login", null);
exports.AuthPasswordController = AuthPasswordController = __decorate([
(0, common_1.Controller)('token/password'),
(0, common_1.UseGuards)(nestjs_auth_local_1.AuthLocalGuard),
(0, nestjs_authentication_1.AuthPublic)(),
(0, swagger_1.ApiTags)('Authentication'),
__param(0, (0, common_1.Inject)(nestjs_auth_local_1.AuthLocalIssueTokenService)),
__metadata("design:paramtypes", [Object])
], AuthPasswordController);
//# sourceMappingURL=auth-password.controller.js.map