This repository has been archived on 2023-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
auth/lib/strategies/local.ts
2023-05-02 01:14:23 -04:00

21 lines
513 B
TypeScript

import passport from 'koa-passport';
import { Strategy } from 'passport-local';
import bcrypt from 'bcrypt';
import Auth from '../model/auth';
import { AuthSchema } from '../schema/auth';
export const LocalStrategy = passport.use(new Strategy(async (username, password, done) => {
const user = await Auth.findOne({
where: {
username,
}
}).catch();
if (user && user.authenticate(password)) {
done(null, user);
} else {
done(null, false);
}
}
));