-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get always "Invalid Credentials" #341
Comments
try to check if the passwords are hashed or not? |
the pwd are hashed (and the user created) in this way: else if ($validation->passes()){ the login is this:
|
update: this is my app/User.php ... i read online that the problem could be here |
return User::create(['email' => $email, 'password' => bcrypt($password)]); with this row it works correctly. (null username) return User::create(['email' => $email, 'password' => bcrypt($password), 'username' => $username]); in this way , it works but with null username (and i cannot understand why) $newuser['email'] = $email; $newuser['username'] = $username; $password=Hash::make('password'); $newuser['password'] = $password; return User::create($newuser); finally in this way it saves the user correctly but the login doest not work... edit: Solved, it works with $password = bcrypt($password); |
This same issue is happening to me using the code in the documentation. |
@joshbodine21 are you doing auth against your App\User model? |
I am having this same problem with my new laravel 5.2 installation (jwt-auth 0.5.6). My users table (in postgresql) is located at: database.schema.members and registering users are working just fine and they appear in DB with hashed passwords. But logging in does not seem to work. However if i change my app to use database.users the register and login are working just fine. Could not get it to work with bcrypt neither... Any ideas? |
anything new with this issue? i get the same problem |
Same issue here. |
Actually this issue is not (not in my case anyway) related to jwt-auth. The "issue" is with laravel and its built in auth functionality. To resolve this i had to define the NAME of password field in my User model: public function getAuthPassword() { And in my AuthController i have to use: So this being said the key is that the "key" of the password field in credientals array MUST be named to "password"... ... this is how i got it working anyway... |
It works fine with Laravel 5.3. My problem is that my post request does not contain 'email' attribute. So maybe you can check your post request to see if there were 'email' and 'password' attribute |
Solved it by creating my users with the password hashed with Laravel's Hash::make function |
Check the length of your password field in DB. Maybe it is truncated |
Solution...If your code is correct, then also if your getting output: Just Follow this Steps:---------------first step check:dd($request->only('email', 'password')); or dd($credentials); array:2 [ second step check:dd($token); false Last Step Goto: App\Config\auth.phpOn line number: 70 Change Model Location where your saved model(User) and On line number: 71 Change Table Name to what you have set in your model(User) 'providers' => [ Happy to help you.... |
watch out with postman? with postman: array (size=2) with curl: array (size=2) so beware.. |
To solve this I just had to encrypt the created user's password, ie. within the signup() controller call:
|
When I create my users using Hash:make it all works fine. Nothing else to do! |
@app\User add a method to set password
@AuthController
It will work fine :) |
What can i do if i would like to change the email column to something else? |
This problem has occurred to me several times |
Hello. I'm having some issues with my laravel api server using JWT.
First of all: I already implemented the same api server and I remember it worked fine.
in this moment it doesn't (I made the old version some months ago).
Basically, I need to implement a register/login functionalities, and the code is the same that worked months ago (it's the common basic-example code for authentication with jwt)
try { if (! $token = JWTAuth::attempt($credentials)) { return response()->json(['error' => 'invalid_credentials'], 401); }
the result I get is ALWAYS invalid credentials. the registration works fine, the DB contains the user, but I can't understand why always the same error...
I already checked: - filesystem permissions - database permissions - source code of my routes/controllers files
Thank you
The text was updated successfully, but these errors were encountered: