-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
afekTheMiniLearner
committed
Sep 26, 2022
1 parent
6e3d4af
commit a456e72
Showing
11 changed files
with
135 additions
and
68 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import passport from 'passport'; | ||
import { Strategy as LocalStrategy } from 'passport-local'; | ||
import bcrypt from 'bcrypt'; | ||
import { UserModel } from '../models/user.model'; | ||
import { findUserByEmail } from '../services/users.services'; | ||
import { passportConfigUser } from '../interfaces/user.interface'; | ||
|
||
passport.use( | ||
new LocalStrategy(async (userEmail, password, done) => { | ||
const user = await findUserByEmail(userEmail); | ||
|
||
if (!user) return done('user not found', null); | ||
|
||
const matchedPassword = await bcrypt.compare(password, user.password); | ||
|
||
if (!matchedPassword) { | ||
return done('user not match password', null); | ||
} | ||
|
||
done(null, user); | ||
}) | ||
); | ||
|
||
passport.serializeUser((user: passportConfigUser | null, done: Function) => { | ||
done(null, user?._id); | ||
}); | ||
|
||
passport.deserializeUser(async (id: string, done: Function) => { | ||
const user = await UserModel.findById(id); | ||
if (!user) done('user not found', null); | ||
else done(null, user); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface IRecipe { | ||
name: string; | ||
creator: string; | ||
ingredients: string; | ||
cookingTime: string; | ||
difficulityLevel: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters