Ferreteria/v2/usage/login

From Woozle Writes Code
< Ferreteria‎ | v2‎ | usage
Revision as of 21:42, 7 June 2015 by htyp>Woozle (PassMatches)
Jump to navigation Jump to search

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>