Programmatically Authenticate User
Permalink
Hello good people!
I am trying to make a custom block to authenticate a user but am having difficulty. So far I have devised the following code:
...however despite the same password being used (and working when logging in via the C5 login screen), the hashed version of the password ($p2) is never the same as $p1.
Anyone ever get this working? Am I missing something? I've been searching around and am not finding much on the internets.
Many thanks in advance for any help!
Cheers,
Alex
I am trying to make a custom block to authenticate a user but am having difficulty. So far I have devised the following code:
$ui = UserInfo::getByUserName($username); $u = $ui->getUserObject(); $p1 = $ui->getUserPassword(); $p2 = $u->getUserPasswordHasher()->HashPassword($password); if($p1==$p2) { echo "Good credentials!" }
...however despite the same password being used (and working when logging in via the C5 login screen), the hashed version of the password ($p2) is never the same as $p1.
Anyone ever get this working? Am I missing something? I've been searching around and am not finding much on the internets.
Many thanks in advance for any help!
Cheers,
Alex
...and it works!