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
mifi 92d43edd7a
All checks were successful
continuous-integration/drone/push Build is passing
Only warning now... Green pipeline?
2023-05-02 11:45:41 -04:00

20 lines
510 B
TypeScript

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