UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

55 lines (54 loc) 2.54 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "AuthMethodDatabase", { enumerable: true, get: function() { return AuthMethodDatabase; } }); const _common = require("@nestjs/common"); const _appconstants = require("../../../app.constants"); const _usersmanagerservice = require("../../../applications/users/services/users-manager.service"); function _ts_decorate(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; } function _ts_metadata(k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); } let AuthMethodDatabase = class AuthMethodDatabase { async validateUser(loginOrEmail, password, ip) { let user; try { user = await this.usersManager.findUser(loginOrEmail, false); } catch (e) { this.logger.error(`${this.validateUser.name} - ${e}`); throw new _common.HttpException(_appconstants.CONNECT_ERROR_CODE.has(e.cause?.code) ? 'Authentication service connection error' : e.message, _common.HttpStatus.INTERNAL_SERVER_ERROR); } if (!user) { this.logger.warn(`${this.validateUser.name} - login or email not found for *${loginOrEmail}*`); return null; } return await this.usersManager.logUser(user, password, ip); } constructor(usersManager){ this.usersManager = usersManager; this.logger = new _common.Logger(AuthMethodDatabase.name); } }; AuthMethodDatabase = _ts_decorate([ (0, _common.Injectable)(), _ts_metadata("design:type", Function), _ts_metadata("design:paramtypes", [ typeof _usersmanagerservice.UsersManager === "undefined" ? Object : _usersmanagerservice.UsersManager ]) ], AuthMethodDatabase); //# sourceMappingURL=auth-method-database.service.js.map