@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
59 lines (58 loc) • 2.56 kB
JavaScript
/*
* 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, "AuthLocalStrategy", {
enumerable: true,
get: function() {
return AuthLocalStrategy;
}
});
const _common = require("@nestjs/common");
const _passport = require("@nestjs/passport");
const _nestjspino = require("nestjs-pino");
const _passportlocal = require("passport-local");
const _authmethod = require("../models/auth-method");
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 AuthLocalStrategy = class AuthLocalStrategy extends (0, _passport.PassportStrategy)(_passportlocal.Strategy, 'local') {
// not declared properly: https://github.com/nestjs/passport/issues/929
async validate(req, loginOrEmail, password) {
this.logger.assign({
user: loginOrEmail
});
const user = await this.authMethod.validateUser(loginOrEmail, password, req.ip);
if (user) {
user.removePassword();
return user;
}
throw new _common.UnauthorizedException('Wrong login or password');
}
constructor(authMethod, logger){
super({
usernameField: 'login',
passwordField: 'password',
passReqToCallback: true
}), this.authMethod = authMethod, this.logger = logger;
}
};
AuthLocalStrategy = _ts_decorate([
(0, _common.Injectable)(),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _authmethod.AuthMethod === "undefined" ? Object : _authmethod.AuthMethod,
typeof _nestjspino.PinoLogger === "undefined" ? Object : _nestjspino.PinoLogger
])
], AuthLocalStrategy);
//# sourceMappingURL=auth-local.strategy.js.map