This commit is contained in:
@@ -6,6 +6,7 @@ import { STRATEGIES } from '../constants/strategies';
|
||||
import { TokenProps, sign, verify as verifyJwt } from '../utils/jwt';
|
||||
import { encrypt, verify as verifyPassword } from '../utils/password';
|
||||
import { generateResetToken } from '../utils/tokens';
|
||||
import { getPasswordResetLink } from '../utils/links';
|
||||
|
||||
export type Auth = {
|
||||
is2FA?: boolean;
|
||||
@@ -65,12 +66,9 @@ AuthSchema.methods = {
|
||||
},
|
||||
|
||||
async getResetLink(route) {
|
||||
const resetToken = await this.getResetToken();
|
||||
if (resetToken) {
|
||||
let resetRoute = route;
|
||||
resetRoute = resetRoute.replace(':user_id', this._id);
|
||||
resetRoute = resetRoute.replace(':reset_token?', resetToken);
|
||||
const resetUrl = `${process.env.URL}${resetRoute}`;
|
||||
const token = await this.getResetToken();
|
||||
if (token) {
|
||||
const resetUrl = getPasswordResetLink(token);
|
||||
console.log('[sendPasswordReset] resetUrl:', resetUrl);
|
||||
return resetUrl;
|
||||
}
|
||||
@@ -109,13 +107,13 @@ AuthSchema.methods = {
|
||||
};
|
||||
|
||||
AuthSchema.statics = {
|
||||
// authenticateAndGetRecordLocator: async function (username, password) {
|
||||
// const auth = await this.findByUserName(username);
|
||||
// if (auth && auth.authenticate(password)) {
|
||||
// return auth?.record;
|
||||
// }
|
||||
// return false;
|
||||
// },
|
||||
authenticateAndGetRecordLocator: async function (username, password) {
|
||||
const auth = await this.findByUsername(username);
|
||||
if (auth && auth.authenticate(password)) {
|
||||
return auth.record;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
async findByUsername(username) {
|
||||
return this.findOne({ username });
|
||||
|
||||
Reference in New Issue
Block a user