Ferreteria/v2/usage/login: Difference between revisions
(key functions used at login time) |
(PassMatches) |
||
Line 37: | Line 37: | ||
} | } | ||
return $oUser; | return $oUser; | ||
} | |||
</php> | |||
clsUserAcct: | |||
<php> | |||
public function PassMatches($iPass) { | |||
// get salt for this user | |||
$sSalt = $this->Value('PassSalt'); | |||
// hash salt+pass | |||
$sHashed = $this->Table()->HashPass($sSalt,$iPass); | |||
// see if it matches | |||
return ($sHashed == $this->Value('PassHash')); | |||
} | } | ||
</php> | </php> |
Revision as of 21:42, 7 June 2015
Data
This uses essentially the same tables as VbzCart/tables#Users -- documentation to be moved here eventually.
Code
clsPageLogin (see pages): <php>
protected function DoLoginCheck() {
$this->App()->Session()->UserLogin($this->LoginName(),$this->sPass);
}
</php> clsUserSession: <php>
/*---- ACTION: Attempts to log the user in with the given credentials. RETURNS: user object if successful, NULL otherwise. */ public function UserLogin($iUser,$iPass) {
$tUsers = $this->UserTable(); $oUser = $tUsers->Login($iUser,$iPass); $this->SetUserRecord($oUser); // set user for this session
}
</php> clsUserAccts: <php>
/*---- RETURNS: user object if login successful, NULL otherwise */ public function Login($iUser,$iPass) {
$rc = $this->FindUser($iUser); if (is_null($rc)) { // username not found $oUser = NULL; } elseif ($rc->AuthValid($iPass)) { $oUser = $rc; } else { // username found, password wrong $oUser = NULL; } return $oUser;
}
</php> clsUserAcct: <php>
public function PassMatches($iPass) {
// get salt for this user $sSalt = $this->Value('PassSalt');
// hash salt+pass $sHashed = $this->Table()->HashPass($sSalt,$iPass); // see if it matches return ($sHashed == $this->Value('PassHash'));
}
</php>