concrete/src/Api/OAuth/Controller.php
public function handleLogin(AuthorizationRequest $request)
    {
        $error = new ErrorList();
        $emailLogin = $this->config->get('concrete.user.registration.email_registration');

        while ($this->request->getMethod() === 'POST') {

            if (!$this->token->validate('oauth_login_' . $request->getClient()->getClientKey())) {
                $error->add($this->token->getErrorMessage());
                break;
            }

            $query = $this->request->getParsedBody();
            $user = array_get($query, 'uName');
            $password = array_get($query, 'uPassword');

            $userRepository = $this->entityManager->getRepository(User::class);

            /** @var User $user */
            $user = $userRepository->findOneBy([$emailLogin ? 'uEmail' : 'uName' => $user]);

            // User successfully logged in
            if ($user && $user->getUserID() && password_verify($password, $user->getUserPassword())) {

                $userInfo = $this->entityManager->find(User::class, $user->getUserID());
                $request->setUser($userInfo);
                $this->storeRequest($request);

                return new \RedirectResponse($this->request->getUri());
            } else {
                $error->add(t('Invalid username or password.'));
            }

            break;
        }

        $contents = $this->createLoginView([
            'error' => $error,
            'auth' => $request,
            'request' => $this->request,
            'client' => $request->getClient(),
            'emailLogin' => $emailLogin
        ]);

        return new \Concrete\Core\Http\Response($contents->render());
    }
public function handleLogin(AuthorizationRequest $request)
    {
        $error = new ErrorList();
        $emailLogin = $this->config->get('concrete.user.registration.email_registration');

        while ($this->request->getMethod() === 'POST') {

            if (!$this->token->validate('oauth_login_' . $request->getClient()->getClientKey())) {
                $error->add($this->token->getErrorMessage());
                break;
            }

            $query = $this->request->getParsedBody();
            $user = array_get($query, 'uName');
            $password = array_get($query, 'uPassword');

            $userRepository = $this->entityManager->getRepository(User::class);

            /** @var User $user */
            $user = $userRepository->findOneBy([$emailLogin ? 'uEmail' : 'uName' => $user]);

            // User successfully logged in
            if ($user && $user->getUserID() && password_verify($password, $user->getUserPassword())) {

                $userInfo = $this->entityManager->find(User::class, $user->getUserID());
                $request->setUser($userInfo);
                $this->storeRequest($request);

                return new \RedirectResponse($this->request->getUri());
            } else {
                $error->add(t('Invalid username or password.'));
            }

            break;
        }

        $contents = $this->createLoginView([
            'error' => $error,
            'auth' => $request,
            'request' => $this->request,
            'client' => $request->getClient(),
            'emailLogin' => $emailLogin
        ]);

        return new \Concrete\Core\Http\Response($contents->render());
    }
public function handleLogin ( AuthorizationRequest $ request ) { $ error = new ErrorList ( ) ; $ emailLogin = $ this -> config -> get ( 'concrete.user.registration.email_registration' ) ; while ( $ this -> request -> getMethod ( ) === 'POST' ) { if ( ! $ this -> token -> validate ( 'oauth_login_' . $ request -> getClient ( ) -> getClientKey ( ) ) ) { $ error -> add ( $ this -> token -> getErrorMessage ( ) ) ; break ; } $ query = $ this -> request -> getParsedBody ( ) ; $ user = array_get ( $ query , 'uName' ) ; $ password = array_get ( $ query , 'uPassword' ) ; $ userRepository = $ this -> entityManager -> getRepository ( User :: class ) ; /** @var User $user */ $ user = $ userRepository -> findOneBy ( [ $ emailLogin ? 'uEmail' : 'uName' => $ user ] ) ; // User successfully logged in if ( $ user && $ user -> getUserID ( ) && password_verify ( $ password , $ user -> getUserPassword ( ) ) ) { $ userInfo = $ this -> entityManager -> find ( User :: class , $ user -> getUserID ( ) ) ; $ request -> setUser ( $ userInfo ) ; $ this -> storeRequest ( $ request ) ; return new \ RedirectResponse ( $ this -> request -> getUri ( ) ) ; } else { $ error -> add ( t ( 'Invalid username or password.' ) ) ; } break ; } $ contents = $ this -> createLoginView ( [ 'error' => $ error , 'auth' => $ request , 'request' => $ this -> request , 'client' => $ request -> getClient ( ) , 'emailLogin' => $ emailLogin ] ) ; return new \ Concrete \ Core \ Http \ Response ( $ contents -> render ( ) ) ; }
Handle the login portion of an authorization request
This method renders a view for login that handles either email or username based login

@param \League\OAuth2\Server\RequestTypes\AuthorizationRequest $request
@return \Concrete\Core\Http\Response|\RedirectResponse
Handle the login portion of an authorization request This method renders a view for login that handles either email or username based login