本文整理匯總了PHP中UserRepository::retrieveUserByUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserRepository::retrieveUserByUsername方法的具體用法?PHP UserRepository::retrieveUserByUsername怎麽用?PHP UserRepository::retrieveUserByUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserRepository
的用法示例。
在下文中一共展示了UserRepository::retrieveUserByUsername方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addUser
public static function addUser($username, $password, $email)
{
$insertSuccessful = self::insertUserIntoDB($username, $password, $email);
if ($insertSuccessful) {
$user = UserRepository::retrieveUserByUsername($username);
return $user;
} else {
return null;
}
}
示例2: login
/**
Sets the current user if the credentials are correct.
returns true if successful; an array of problems if the inputs are invalid
*/
public function login($username, $password)
{
$result = $this->loginInputIsValid($username, $password);
if ($result !== true) {
return $result;
} else {
$user = UserRepository::retrieveUserByUsername($username);
if ($user === null) {
$problem = array('badUsername' => true);
return $problem;
} else {
if ($user->passwordMatches($password)) {
print "logged in";
$this->currentUser = $user;
return true;
} else {
$problem = array('badPassword' => true);
return $problem;
}
}
}
}
示例3: usernameIsAvailable
private static function usernameIsAvailable($username)
{
$result = UserRepository::retrieveUserByUsername($username);
$usernameIsAvailable = $result === null;
return $usernameIsAvailable;
}