Files
tabungin/apps/api/dist/auth/auth.controller.js
dwindown 89f881e7cf feat: reorganize admin settings with tabbed interface and documentation
- Reorganized admin settings into tabbed interface (General, Security, Payment Methods)
- Vertical tabs on desktop, horizontal scrollable on mobile
- Moved Payment Methods from separate menu to Settings tab
- Fixed admin profile reuse and dashboard blocking
- Fixed maintenance mode guard to use AppConfig model
- Added admin auto-redirect after login (admins → /admin, users → /)
- Reorganized documentation into docs/ folder structure
- Created comprehensive README and documentation index
- Added PWA and Web Push notifications to to-do list
2025-10-13 09:28:12 +07:00

118 lines
5.2 KiB
JavaScript

"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 common_1 = require("@nestjs/common");
const auth_guard_1 = require("./auth.guard");
const passport_1 = require("@nestjs/passport");
const auth_service_1 = require("./auth.service");
const skip_maintenance_decorator_1 = require("../common/decorators/skip-maintenance.decorator");
let AuthController = class AuthController {
authService;
constructor(authService) {
this.authService = authService;
}
async register(body) {
return this.authService.register(body.email, body.password, body.name);
}
async login(body) {
return this.authService.login(body.email, body.password);
}
async verifyOtp(body) {
return this.authService.verifyOtpAndLogin(body.tempToken, body.otpCode, body.method);
}
async googleAuth() {
}
async googleAuthCallback(req, res) {
const result = await this.authService.googleLogin(req.user);
const frontendUrl = process.env.WEB_APP_URL || 'http://localhost:5174';
if (result.requiresOtp) {
res.redirect(`${frontendUrl}/auth/otp?token=${result.tempToken}&methods=${JSON.stringify(result.availableMethods)}`);
}
else {
res.redirect(`${frontendUrl}/auth/callback?token=${result.token}`);
}
}
async getProfile(req) {
return this.authService.getUserProfile(req.user.userId);
}
async changePassword(req, body) {
return this.authService.changePassword(req.user.userId, body.currentPassword, body.newPassword, body.isSettingPassword);
}
};
exports.AuthController = AuthController;
__decorate([
(0, common_1.Post)('register'),
(0, skip_maintenance_decorator_1.SkipMaintenance)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "register", null);
__decorate([
(0, common_1.Post)('login'),
(0, skip_maintenance_decorator_1.SkipMaintenance)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "login", null);
__decorate([
(0, common_1.Post)('verify-otp'),
(0, skip_maintenance_decorator_1.SkipMaintenance)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "verifyOtp", null);
__decorate([
(0, common_1.Get)('google'),
(0, skip_maintenance_decorator_1.SkipMaintenance)(),
(0, common_1.UseGuards)((0, passport_1.AuthGuard)('google')),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], AuthController.prototype, "googleAuth", null);
__decorate([
(0, common_1.Get)('google/callback'),
(0, skip_maintenance_decorator_1.SkipMaintenance)(),
(0, common_1.UseGuards)((0, passport_1.AuthGuard)('google')),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "googleAuthCallback", null);
__decorate([
(0, common_1.Get)('me'),
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "getProfile", null);
__decorate([
(0, common_1.Post)('change-password'),
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], AuthController.prototype, "changePassword", null);
exports.AuthController = AuthController = __decorate([
(0, common_1.Controller)('auth'),
__metadata("design:paramtypes", [auth_service_1.AuthService])
], AuthController);
//# sourceMappingURL=auth.controller.js.map