Page 1 of 1

Redirect to Changepassword page on default password

Posted: Thu Apr 25, 2024 2:20 pm
by JAYM

Redirect to Changepassword page on default password
I want to add function where if it detect the password of user when default password="12345" it will redirect to changepassword page upon logging in.
I tried to put the code to custom scripts but it doest work.
Please help thank you.

$userid = CurrentUserID();
    $pswd = ExecuteScalar("SELECT password FROM userlogin WHERE id='$userid'");

    if ($pswd == "12345"){
        header('Location: changepassword');
    } else{
      header('Location: home');
    }

Re: Redirect to Changepassword page on default password

Posted: Thu Apr 25, 2024 2:27 pm
by mobhar

Are you sure the password in users table are stored as plain text (not ecrypted)?


Re: Redirect to Changepassword page on default password

Posted: Thu Apr 25, 2024 2:28 pm
by JAYM

Yes the password is not encrypted and its just plain text


Re: Redirect to Changepassword page on default password

Posted: Thu Apr 25, 2024 5:16 pm
by mobhar

In which server event did you put that code?


Re: Redirect to Changepassword page on default password

Posted: Fri Apr 26, 2024 7:54 am
by JAYM

I put the code here but is doesnt work
Global -> All Pages -> Page_loading
Global -> All Pages -> User_Validated
Table Specific -> Login Page -> UserLoggedIn


Re: Redirect to Changepassword page on default password

Posted: Fri Apr 26, 2024 9:33 am
by mobhar

You should only put the code in User_LoggedIn server event.

In addition, change this part:
header('Location: changepassword');

to:
$this->terminate('changepassword');

and this part:
header('Location: home');

to:
$this->terminate('home');


Re: Redirect to Changepassword page on default password

Posted: Fri Apr 26, 2024 10:47 am
by JAYM

Thanks its working now.