Advertisement
Guest User

sqdfqfd

a guest
May 27th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. try
  2. {
  3. $user = $this->client->post('auth', 'login', [
  4. 'username' => $username,
  5. 'password' => $password,
  6. ]);
  7.  
  8. $this->userRepository->updateUser(array_get($user, 'user_identifier', ''), [
  9. 'fname' => array_get($user, 'fname', ''),
  10. 'lname' => array_get($user, 'lname', ''),
  11. 'email' => array_get($user, 'email', ''),
  12. 'username' => array_get($user, 'username', ''),
  13. 'local' => 0,
  14. ]);
  15.  
  16. $this->syncRoles(array_get($user, 'user_identifier', ''), array_get($user, 'roles', [ ]));
  17. }
  18. catch (\Exception $e)
  19. {
  20. if ( $e->getCode() === 401 || $e->getCode() === 403 )
  21. {
  22. throw new InvalidCredentialsException;
  23. }
  24. else
  25. {
  26. $userResolver = $this->oauth2UserRepository->find($username);
  27.  
  28. if ( $userResolver->getPassword() == null )
  29. throw new InvalidCredentialsException;
  30.  
  31. if ( $password == $userResolver->getPassword() )
  32. {
  33. return $this->oauth2SessionRepository->create($userResolver->getIdentifier())->getAttributes();
  34. };
  35.  
  36. throw new InvalidCredentialsException;
  37. }
  38. }
  39.  
  40. return $this->oauth2SessionRepository->create(
  41. $this->userRepository->findByUsername($username)->id
  42. )->getAttributes();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement