简体   繁体   中英

Adonisjs Authentication Password mismatch error

I'm using the Adonis Framework to create a login from their authentication tutorial. I have a working register (I have a page retrieving all profiles that were created), but when I try to login with one of the users, I am getting a password mismatch error thrown. I am hashing passwords before they are store and have tried taking that feature out, but it broke the site as well. Anyone else have this problem or know how to fix it?

'use strict'

const User = use('App/Model/User')
const Hash = use('Hash')

class AuthController {
    * index(request, response) {
    yield response.sendView('login')
    }
    * login(request, response) {
       const email = request.input('email')
       const password = request.input('password')

       const login = yield request.auth.attempt(email, password)
       if(login) {
         response.send('Welcome Back!')
         return
       }

       response.unauthorized('Invalid credentials: Try Again!')
       }

    * logout(request, response) {
      yield request.auth.logout()
      return response.redirect('/')
    }

 }

module.exports = AuthController

Check that you are using the "yield" keyword in your hash statement. or check the length of your database field, probably the hash is bigger than the field

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM