Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const checkPassword = (username, password) => {
  2. return new Promise(async (resolve,reject) => {
  3. try{
  4. const userModel = getUserModel();
  5. const user = await userModel.findOne({where: { username } });
  6. const correctPassword = validPassword(password,user.password);
  7. console.log("sanity check corr password " + correctPassword);
  8. resolve(correctPassword);
  9. //return a token??
  10. }
  11. catch(error) {
  12. reject(error);
  13. }
  14. });
  15. };
  16.  
  17.  
  18. let correctPassword;
  19. try {
  20. correctPassword = await checkPassword(username, password);
  21. } catch (error) {
  22. console.log('something went wrong when checking your password');
  23. }
  24.  
  25.  
  26. if(correctPassword) {
  27. console.log("LOGIN SUCCESSFULL");
  28. } else {
  29. console.log("LOGIN UNSUCCESSFULL");
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement