concrete/src/Api/OAuth/Controller.php
public function authorize()
    {
        $response = new Response();

        try {
            $request = $this->getAuthorizationRequest();
            $step = $this->determineStep($request);

            // Handle login step
            if ($step === self::STEP_LOGIN) {
                if (!$this->user) {
                    return $this->handleLogin($request);
                }

                // We have a fully logged in user, let's just use that
                $userEntity = $this->entityManager->find(User::class, $this->user->getUserID());
                $request->setUser($userEntity);
                $this->storeRequest($request);

                // Update the step
                $step = $this->determineStep($request);
            }

            // Handle authorize step
            if ($step === self::STEP_AUTHORIZE_CLIENT) {
                if ($this->getConsentType($request) !== Client::CONSENT_NONE) {
                    return $this->handleAuthorizeClient($request);
                }

                // Otherwise if consent is disabled just mark this request as approved.
                $request->setAuthorizationApproved(true);
                $this->storeRequest($request);
            }

            // We've fallen through all the other steps...
            $this->clearRequest($request);
            return $this->oauthServer->completeAuthorizationRequest($request, $response);
        } catch (OAuthServerException $exception) {
            return $exception->generateHttpResponse($response);
        } catch (\Exception $exception) {
            $body = new LazyOpenStream('php://temp', 'r+');
            $body->write($exception->getMessage());
            return $response->withStatus(500)->withBody($body);
        }
    }
public function authorize()
    {
        $response = new Response();

        try {
            $request = $this->getAuthorizationRequest();
            $step = $this->determineStep($request);

            // Handle login step
            if ($step === self::STEP_LOGIN) {
                if (!$this->user) {
                    return $this->handleLogin($request);
                }

                // We have a fully logged in user, let's just use that
                $userEntity = $this->entityManager->find(User::class, $this->user->getUserID());
                $request->setUser($userEntity);
                $this->storeRequest($request);

                // Update the step
                $step = $this->determineStep($request);
            }

            // Handle authorize step
            if ($step === self::STEP_AUTHORIZE_CLIENT) {
                if ($this->getConsentType($request) !== Client::CONSENT_NONE) {
                    return $this->handleAuthorizeClient($request);
                }

                // Otherwise if consent is disabled just mark this request as approved.
                $request->setAuthorizationApproved(true);
                $this->storeRequest($request);
            }

            // We've fallen through all the other steps...
            $this->clearRequest($request);
            return $this->oauthServer->completeAuthorizationRequest($request, $response);
        } catch (OAuthServerException $exception) {
            return $exception->generateHttpResponse($response);
        } catch (\Exception $exception) {
            $body = new LazyOpenStream('php://temp', 'r+');
            $body->write($exception->getMessage());
            return $response->withStatus(500)->withBody($body);
        }
    }
public function authorize ( ) { $ response = new Response ( ) ; try { $ request = $ this -> getAuthorizationRequest ( ) ; $ step = $ this -> determineStep ( $ request ) ; // Handle login step if ( $ step === self :: STEP_LOGIN ) { if ( ! $ this -> user ) { return $ this -> handleLogin ( $ request ) ; } // We have a fully logged in user, let's just use that $ userEntity = $ this -> entityManager -> find ( User :: class , $ this -> user -> getUserID ( ) ) ; $ request -> setUser ( $ userEntity ) ; $ this -> storeRequest ( $ request ) ; // Update the step $ step = $ this -> determineStep ( $ request ) ; } // Handle authorize step if ( $ step === self :: STEP_AUTHORIZE_CLIENT ) { if ( $ this -> getConsentType ( $ request ) !== Client :: CONSENT_NONE ) { return $ this -> handleAuthorizeClient ( $ request ) ; } // Otherwise if consent is disabled just mark this request as approved. $ request -> setAuthorizationApproved ( true ) ; $ this -> storeRequest ( $ request ) ; } // We've fallen through all the other steps... $ this -> clearRequest ( $ request ) ; return $ this -> oauthServer -> completeAuthorizationRequest ( $ request , $ response ) ; } catch ( OAuthServerException $ exception ) { return $ exception -> generateHttpResponse ( $ response ) ; } catch ( \ Exception $ exception ) { $ body = new LazyOpenStream ( 'php://temp' , 'r+' ) ; $ body -> write ( $ exception -> getMessage ( ) ) ; return $ response -> withStatus ( 500 ) -> withBody ( $ body ) ; } }
Route handler that deals with authorization

@return \Psr\Http\Message\ResponseInterface|\Concrete\Core\Http\Response
Route handler that deals with authorization