本文整理汇总了PHP中UserRepository类的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository类的具体用法?PHP UserRepository怎么用?PHP UserRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: viewAccountAction
/**
* GET /account(/:name).
*
* @param null|string $name
*/
public function viewAccountAction($name = null)
{
$redis = $this->app->container->get('redis.client');
$userRepository = new UserRepository($redis);
$user = $userRepository->find($name);
$jsonPath = $this->app->config('json_path') . 'users/github/' . $name . '.json';
$this->app->notFoundIf(file_exists($jsonPath) === false)->redirectUnless($name, '/profile')->render('account.html', ['account' => $user]);
}
开发者ID:Doanlmit,项目名称:pickleweb,代码行数:13,代码来源:UserController.php
示例2: ChangePassword
public static function ChangePassword($oldPassword, $newPassword)
{
$userRepository = new UserRepository();
$user = $userRepository->LoadWhere("Id = " . self::$userId)[0];
if ($user["Password"] == self::Encode($oldPassword)) {
$userRepository->UpdateWhere("Id = " . self::$userId, ["Password" => self::Encode($newPassword)]);
return true;
} else {
return false;
}
}
开发者ID:BrunnerLivio,项目名称:Bierbendiger,代码行数:11,代码来源:AuthRepository.php
示例3: userLogin
/**
* log the user - if not exists register him/her and then log the user
*
* @return void
*/
public static function userLogin()
{
$errors = array();
$hash = addslashes(Utils::get('hash'));
if ($hash) {
$userRepository = new UserRepository();
$user = $userRepository->getOneByHash($hash);
} else {
if (Utils::post('username') != '') {
$username = addslashes(Utils::post('username'));
if (!ctype_alnum($username)) {
$errors['username'] = 'V používateľskom mene môžeš použiť len alfanumerické znaky';
// TODO localize
}
} else {
$errors['username'] = 'Musíš vyplniť používateľské meno';
// TODO localize
}
if (Utils::post('password') != '') {
$password = md5(addslashes(Utils::post('password')));
} else {
$errors['password'] = 'Musíš vyplniť heslo';
// TODO localize
}
if (empty($errors)) {
$userRepository = new UserRepository();
$userExist = $userRepository->getOneByUsername($username);
if ($userExist === NULL) {
$colorRepository = new ColorRepository();
$count = $colorRepository->getCountAll();
$rand = rand(1, $count);
$params = array('username' => $username, 'password' => $password, 'color' => $rand);
$user = new User($params);
$user = $user->save(TRUE);
} elseif ($userExist['password'] != $password) {
$errors['password'] = 'Nesprávne heslo';
} else {
$user = $userExist;
}
}
}
if ($user && empty($errors)) {
// TODO po prihlaseni treba nejako zmazat v memcachi query, ktora vybera usera podla cookie_value
// lebo teraz to stale vracia vysledok z memcache -> ked sa prihlasim v dvoch browsroch, v obidvoch to funguje
// neodhlasi ma z toho prveho
$cookieValue = md5(time() . $user['id'] . $user['username']);
DB::update(DB_PREFIX . 'user', array('cookie_value' => $cookieValue), 'id = ' . $user['id']);
$expire = Utils::post('remember') == 1 ? strtotime('+1 year') : 0;
setcookie(self::$cookieName, $cookieValue, $expire, '/');
return TRUE;
} else {
return $errors;
}
}
开发者ID:Tomeno,项目名称:lulcobang,代码行数:59,代码来源:LoggedUser.php
示例4: __construct
public function __construct()
{
parent::__construct();
$this->create_guest_account = function () {
return UserRepository::createWithRoles(['UserID' => 1, 'Name' => 'Anonymous', 'Password' => str_random(64), 'HashMethod' => 'random'], [RoleRepository::member()]);
};
}
开发者ID:bishopb,项目名称:laravel-forums,代码行数:7,代码来源:UserMapperAllGuestAccess.php
示例5: ShowUserAttributes
public function ShowUserAttributes()
{
// User attributes on Dashboard, Added by Burak C.
$userId = ServiceLocator::GetServer()->GetUserSession()->UserId;
$userRepository = new UserRepository();
$this->user = $userRepository->LoadById($userId);
$attributeService = new AttributeService(new AttributeRepository());
$attributes = $attributeService->GetByCategory(CustomAttributeCategory::USER);
$reservationViewRepository = new ReservationViewRepository();
$startDate = Date::Now();
$endDate = $startDate->AddDays(30);
$reservations = $reservationViewRepository->GetReservationList($startDate, $endDate, $userId, ReservationUserLevel::INVITEE);
$this->_page->Set("invitations", $reservations);
$this->_page->Set("user", $this->user);
$this->_page->Set("attributes", $attributes);
}
开发者ID:ViraSoftware,项目名称:booked,代码行数:16,代码来源:DashboardPresenter.php
示例6: SendRandomPassword
public function SendRandomPassword()
{
$emailAddress = $this->_page->GetEmailAddress();
Log::Debug('Password reset request for email address %s requested from REMOTE_ADDR: %s REMOTE_HOST: %s', $emailAddress, $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_HOST']);
$temporaryPassword = Password::GenerateRandom();
$passwordEncryption = new PasswordEncryption();
$salt = $passwordEncryption->Salt();
$encrypted = $passwordEncryption->Encrypt($temporaryPassword, $salt);
$userRepository = new UserRepository();
$user = $userRepository->FindByEmail($emailAddress);
if ($user != null) {
$user->ChangePassword($encrypted, $salt);
$userRepository->Update($user);
$emailMessage = new ForgotPasswordEmail($user, $temporaryPassword);
ServiceLocator::GetEmailService()->Send($emailMessage);
}
}
开发者ID:hugutux,项目名称:booked,代码行数:17,代码来源:ForgotPwdPresenter.php
示例7: isSatisfiedBy
/**
* Check to see if the specification is satisfied
*
* @param Username $username
* @return bool
*/
public function isSatisfiedBy(Username $username)
{
if (!$this->repository->userOfUsername($username)) {
return true;
}
return false;
}
开发者ID:alle,项目名称:cribbb,代码行数:13,代码来源:UsernameIsUnique.php
示例8: compose
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
if (!Cache::get('recent_posts')) {
Cache::put('recent_posts', $this->posts->getAll('published', null, 'published_at', 'desc', 5), 10);
}
$view->with('recent_posts', Cache::get('recent_posts'));
}
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:13,代码来源:RecentPostsComposer.php
示例9: handleSave
public function handleSave(Form $form)
{
$values = $form->values;
if ($values['file']->isOk()) {
if ($values['cleanout']) {
foreach ($this->userRepository->findAll() as $user) {
$this->userRepository->delete($user);
}
}
/** @var FileUpload $file */
$file = $values['file'];
$data = file_get_contents($file->getTemporaryFile());
foreach (explode("\n", $data) as $row) {
if (!$row) {
continue;
}
$items = explode(',', $row);
if (!count($items)) {
continue;
}
try {
$user = new UserEntity(trim($items[0]));
} catch (InvalidArgumentException $e) {
$form->addError($e->getMessage());
}
$this->userRepository->save($user);
}
}
}
开发者ID:venne,项目名称:newsletter-module,代码行数:29,代码来源:ImportFormFactory.php
示例10: isSatisfiedBy
/**
* Check to see if the specification is satisfied
*
* @param Email $email
* @return bool
*/
public function isSatisfiedBy(Email $email)
{
if (!$this->repository->userOfEmail($email)) {
return true;
}
return false;
}
开发者ID:alle,项目名称:cribbb,代码行数:13,代码来源:EmailIsUnique.php
示例11: it_unfollows_another_user
/** @test */
public function it_unfollows_another_user()
{
$users = TestDummy::times(2)->create('Larabook\\Users\\User');
$this->repo->follow($users[1]->id, $users[0]);
$this->repo->unfollow($users[1]->id, $users[0]);
$this->tester->dontSeeRecord('follows', ['follower_id' => $users[0]->id, 'followed_id' => $users[1]->id]);
}
开发者ID:atolver,项目名称:larabook,代码行数:8,代码来源:UserRepositoryTest.php
示例12: unFollowUser
/**
* UnFollow user
*
* @param $input
* @return mixed
*/
public function unFollowUser($input)
{
$user = $this->userRepo->findById($input['user_id']);
$userToUnFollow = $this->userRepo->findById($input['userIdToUnFollow']);
$this->albumRepo->unShareAllAlbums($user, $userToUnFollow);
return $this->userRepo->unFollow($input['userIdToUnFollow'], $user);
}
开发者ID:kriminal666,项目名称:crimibook,代码行数:13,代码来源:FollowRepository.php
示例13: UpdateProfile
private function UpdateProfile(User $user)
{
$user->ChangeEmailPreference(new ReservationApprovedEvent(), $this->page->GetApproved());
$user->ChangeEmailPreference(new ReservationCreatedEvent(), $this->page->GetCreated());
$user->ChangeEmailPreference(new ReservationUpdatedEvent(), $this->page->GetUpdated());
$user->ChangeEmailPreference(new ReservationDeletedEvent(), $this->page->GetDeleted());
$this->userRepository->Update($user);
}
开发者ID:Trideon,项目名称:gigolo,代码行数:8,代码来源:NotificationPreferencesPresenter.php
示例14: should_register_new_user
/** @test */
public function should_register_new_user()
{
$this->repository->shouldReceive('userOfEmail')->once()->andReturn(null);
$this->repository->shouldReceive('userOfUsername')->once()->andReturn(null);
$this->repository->shouldReceive('nextIdentity')->once()->andReturn(UserId::generate());
$this->repository->shouldReceive('add')->once();
$user = $this->service->register('[email protected]', 'username', 'password');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
}
开发者ID:kfuchs,项目名称:cribbb,代码行数:10,代码来源:UserRegistrationTest.php
示例15: should_allow_user_to_join_the_group
/** @test */
public function should_allow_user_to_join_the_group()
{
$user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
$group = m::mock('Cribbb\\Domain\\Model\\Groups\\Group');
$group->shouldReceive('addMember')->once();
$this->users->shouldReceive('userById')->once()->andReturn($user);
$this->groups->shouldReceive('groupById')->once()->andReturn($group);
$group = $this->service->join('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group);
}
开发者ID:kfuchs,项目名称:cribbb,代码行数:11,代码来源:JoinGroupTest.php
示例16: authenticate
/**
* Using the given email finds the user and verifies it's password.
* If the user is not fund or if the password is wrong, it throws.
*
* @param array $credentials
* @throws AuthenticationException
* @return User|NULL
*/
public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
if (!($user = $this->userRepository->findOneBy(['email' => $username]))) {
throw new AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
} elseif (!$user->verifyPassword($password)) {
throw new AuthenticationException('Invalid password.', self::INVALID_CREDENTIAL);
}
return $user;
}
开发者ID:martinmayer,项目名称:notejam,代码行数:18,代码来源:Authenticator.php
示例17: should_reset_password_and_return_user
/** @test */
public function should_reset_password_and_return_user()
{
$reminder = new Reminder($this->fixture['id'], $this->fixture['email'], $this->fixture['code']);
$this->reminders->shouldReceive('findReminderByEmailAndCode')->andReturn($reminder);
$this->users->shouldReceive('userOfEmail')->andReturn($this->user);
$this->hasher->shouldReceive('hash')->andReturn(new HashedPassword('qwerty123'));
$this->users->shouldReceive('update');
$this->reminders->shouldReceive('deleteReminderByCode');
$user = $this->service->reset('[email protected]', 'qwerty123', 'abc123');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
}
开发者ID:kfuchs,项目名称:cribbb,代码行数:12,代码来源:ReminderServiceTest.php
示例18: should_register_new_user
/** @test */
public function should_register_new_user()
{
$this->repository->shouldReceive('userOfEmail')->andReturn(null);
$this->repository->shouldReceive('userOfUsername')->andReturn(null);
$this->repository->shouldReceive('nextIdentity')->andReturn($this->uuid);
$this->hashing->shouldReceive('hash')->andReturn($this->password);
$this->repository->shouldReceive('add');
$this->dispatcher->shouldReceive('dispatch');
$user = $this->service->registerUser('[email protected]', 'username', 'password');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
}
开发者ID:snb4crazy,项目名称:cribbb,代码行数:12,代码来源:IdentityApplicationServiceTest.php
示例19: should_create_new_post
/** @test */
public function should_create_new_post()
{
$user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
$thread = m::mock('Cribbb\\Domain\\Model\\Discussion\\Thread');
$post = m::mock('Cribbb\\Domain\\Model\\Discussion\\Post');
$this->users->shouldReceive('userById')->once()->andReturn($user);
$this->threads->shouldReceive('threadById')->once()->andReturn($thread);
$thread->shouldReceive('createNewPost')->once()->andReturn($post);
$this->posts->shouldReceive('add')->once();
$post = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f', 'Hello World');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
}
开发者ID:kfuchs,项目名称:cribbb,代码行数:13,代码来源:NewPostTest.php
示例20: should_create_new_thread
/** @test */
public function should_create_new_thread()
{
$user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
$group = m::mock('Cribbb\\Domain\\Model\\Groups\\Group');
$thread = m::mock('Cribbb\\Domain\\Model\\Discussion\\Thread');
$this->users->shouldReceive('userById')->once()->andReturn($user);
$this->groups->shouldReceive('groupById')->once()->andReturn($group);
$group->shouldReceive('startNewThread')->once()->andReturn($thread);
$this->threads->shouldReceive('add')->once();
$thread = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f', 'Hello World');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Thread', $thread);
}
开发者ID:kfuchs,项目名称:cribbb,代码行数:13,代码来源:NewThreadTest.php
注:本文中的UserRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论