Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. async login(){
  2. this.username = this.request.body.username;
  3. this.password = this.request.body.password;
  4. let user = await this.database.penguin.findOne({where: {Username: this.username}});
  5. let password = user.Password.replace(/^\$2y(.+)$/i, '$2a$1');
  6.  
  7.  
  8. if(!await this.checkRow(`Username`, this.username)){
  9. this.type = 'username_not_found';
  10. this.response.render('index', this.displaySite());
  11. }
  12.  
  13. else if(!await bcrypt.compare(await this.getHash(), password)){
  14. this.type = 'incorrect_password';
  15. this.response.render('index', this.displaySite());
  16. }
  17.  
  18. else{
  19. this.request.session.loggedin = true;
  20. this.request.session.username = this.username;
  21. this.response.redirect('/panel');
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement