本文整理汇总了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;
}