Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- $user = $this->client->post('auth', 'login', [
- 'username' => $username,
- 'password' => $password,
- ]);
- $this->userRepository->updateUser(array_get($user, 'user_identifier', ''), [
- 'fname' => array_get($user, 'fname', ''),
- 'lname' => array_get($user, 'lname', ''),
- 'email' => array_get($user, 'email', ''),
- 'username' => array_get($user, 'username', ''),
- 'local' => 0,
- ]);
- $this->syncRoles(array_get($user, 'user_identifier', ''), array_get($user, 'roles', [ ]));
- }
- catch (\Exception $e)
- {
- if ( $e->getCode() === 401 || $e->getCode() === 403 )
- {
- throw new InvalidCredentialsException;
- }
- else
- {
- $userResolver = $this->oauth2UserRepository->find($username);
- if ( $userResolver->getPassword() == null )
- throw new InvalidCredentialsException;
- if ( $password == $userResolver->getPassword() )
- {
- return $this->oauth2SessionRepository->create($userResolver->getIdentifier())->getAttributes();
- };
- throw new InvalidCredentialsException;
- }
- }
- return $this->oauth2SessionRepository->create(
- $this->userRepository->findByUsername($username)->id
- )->getAttributes();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement