src/Synapse/OAuth2/OAuthController.php
public function token(Request $request)
    {
        $bridgeResponse = new BridgeResponse;
        $oauthRequest   = OAuthRequest::createFromRequest($request);
        $response       = $this->server->handleTokenRequest($oauthRequest, $bridgeResponse);

        if ($response->isOk()) {
            $user = $this->userService->findById($response->getParameter('user_id'));

            if (! $user) {
                return $this->createInvalidCredentialResponse();
            }

            if (! $user->getEnabled()) {
                return $this->createInvalidCredentialResponse();
            }

            // If enabled in config, check that user is verified
            if ($this->requireVerification && ! $user->getVerified()) {
                return $this->createSimpleResponse(422, 'Unverified user');
            }

            $userId = $response->getParameter('user_id');

            $this->setLastLogin($userId);

            $this->session->set('user', $userId);
        }

        return $response;
    }
public function token(Request $request)
    {
        $bridgeResponse = new BridgeResponse;
        $oauthRequest   = OAuthRequest::createFromRequest($request);
        $response       = $this->server->handleTokenRequest($oauthRequest, $bridgeResponse);

        if ($response->isOk()) {
            $user = $this->userService->findById($response->getParameter('user_id'));

            if (! $user) {
                return $this->createInvalidCredentialResponse();
            }

            if (! $user->getEnabled()) {
                return $this->createInvalidCredentialResponse();
            }

            // If enabled in config, check that user is verified
            if ($this->requireVerification && ! $user->getVerified()) {
                return $this->createSimpleResponse(422, 'Unverified user');
            }

            $userId = $response->getParameter('user_id');

            $this->setLastLogin($userId);

            $this->session->set('user', $userId);
        }

        return $response;
    }
public function token ( Request $ request ) { $ bridgeResponse = new BridgeResponse ; $ oauthRequest = OAuthRequest :: createFromRequest ( $ request ) ; $ response = $ this -> server -> handleTokenRequest ( $ oauthRequest , $ bridgeResponse ) ; if ( $ response -> isOk ( ) ) { $ user = $ this -> userService -> findById ( $ response -> getParameter ( 'user_id' ) ) ; if ( ! $ user ) { return $ this -> createInvalidCredentialResponse ( ) ; } if ( ! $ user -> getEnabled ( ) ) { return $ this -> createInvalidCredentialResponse ( ) ; } // If enabled in config, check that user is verified if ( $ this -> requireVerification && ! $ user -> getVerified ( ) ) { return $ this -> createSimpleResponse ( 422 , 'Unverified user' ) ; } $ userId = $ response -> getParameter ( 'user_id' ) ; $ this -> setLastLogin ( $ userId ) ; $ this -> session -> set ( 'user' , $ userId ) ; } return $ response ; }
Handle an OAuth token request

(Implements the "Resource Owner Password Credentials" grant type
or Part 3 of the "Authorization Code" grant type)

Note: Expects input as POST variables, not JSON request body

@link http://tools.ietf.org/html/rfc6749#section-4.3.2 Access Token Request
@param  Request $request
@return Response
Handle an OAuth token request