benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.35k stars 1.14k forks source link

reset password not working properly on function forgotten_password_check($code) and email send #1565

Closed webmestudio closed 1 year ago

webmestudio commented 2 years ago

please fix this, if i apply the default code $user = $this->ion_auth->forgotten_password_check($code); reset password doesn't work properly and $user returns null,

i have changed to $user = $this->ion_auth->where('forgotten_password_selector', $code)->users()->row(); and it works fine but the password reset link to email doesn't work

benedmunds commented 2 years ago

forgotten_password_check uses a token, not the straight code. Can you make sure you're on the latest commit?

BobMoir commented 1 year ago

i am facing the same problem as wscdn. To make sure i am using the latest commit. i have downloaded it again but $user = $this->ion_auth->forgotten_password_check($code) still returns NULL. Kindly help

benedmunds commented 1 year ago

Is a valid code being passed in?

BobMoir commented 1 year ago

It was working in earlier version of Ion Auth but not working in this latest Ion Auth and this is the CODE i have passed:

http://localhost/myproject/auth/reset_password/7308f3219d9621a035dd.3bea8e819f1067823cfc1c44e84b0d0642cc5553a2edc2a35175f94fddf430d5b3b43e07fc99bd8f

also not working on live server:

https://www.xxxxxxx.com/auth/reset_password/7308f3219d9621a035dd.3bea8e819f1067823cfc1c44e84b0d0642cc5553a2edc2a35175f94fddf430d5b3b43e07fc99bd8f

BobMoir commented 1 year ago

Kindly help me

benedmunds commented 1 year ago

Hey, just got back from vacation. Are you able to reproduce this with a fresh download of Ion Auth in a brand new app? Or just in your existing app?

If only the existing app, can you email me a stripped down version of it that I can run locally to reproduce? Then I’ll see what I can figure out.

BobMoir commented 1 year ago

Thanks for replying. Please give me a day or two and i shall make a new small app just with the Login and Forgot Password and share it with you.

benedmunds commented 1 year ago

Sounds good!

BobMoir commented 1 year ago

Too excited after reading your generous reply, I immediately made a small app. Kindly check and solve this problem of mine. Please find the attached zip file. I use identity as Username and not Email. Login is Admin and Password is 123456.

BobMoir commented 1 year ago

Is this ok or shall i email you @ ben@benedmunds.com ?

benedmunds commented 1 year ago

This works, thanks! I’ll review later today or tomorrow.

BobMoir commented 1 year ago

Thank you. i shall be waiting for it ...

benedmunds commented 1 year ago

Hey @BobMoir , I looked through it and found the issue.

Your hash fields are too small in your database. Right now they're varchar(40) but should be var_char(255), the 40 limitation is causing the hashes to be trucated when inserted into the database.

I would update all of the following fields:

activation_code
forgotten_password_code
remember_code
password

I would double check the other fields as well. Note the latest schema in github for reference: https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/3/sql/ion_auth.sql

Take care!

BobMoir commented 1 year ago

THanks a lot. Now, the reset password page is opening but when i tried to change/reset password is says : The field cannot exceed characters in length. Kindly check

benedmunds commented 1 year ago

I'm not at a computer atm, troubleshoot that a bit and see. That's not an Ion Auth error message, sounds like a validation error or maybe a DB error...

BobMoir commented 1 year ago

Sorry, i just sent that message before i check out of excitement. Its my fault that i mixed my old codes with the new ones. in the earlier version |max_length[' . $this->config->item('max_password_length', 'ion_auth') . '] was there and in the new version max_password_length is removed and i did not remove it on the form validation. Now its working like a charm. Thank you thanks a lot.

benedmunds commented 1 year ago

Awesome, glad to hear it’s working!