Store a new password grant client.

@param  int  $userId
@param  string  $name
@param  string  $redirect
@return \Laravel\Passport\Client
484600
public function createPasswordGrantClient($userId, $name, $redirect)
    {
        return $this->create($userId, $name, $redirect, false, true);
    }
567173
public function assign($userId, $name)
    {
        if ($this->searchRoleRecursive($this->roles, $name)) {
            $exists = $this->db->exists('rbac_user', ['user' => $userId, 'role' => $name]);
            if (!$exists) {
                return $this->db->insert('rbac_user', ['role' => $name, 'user' => $userId]);
            }
        }

        return false;
    }
1038650
public function createClient($identifier, array $redirect_uris = array(), array $grant_types = array(), array $scopes = array())
    {
        $client = new \OAuth2\ServerBundle\Entity\Client();
        $client->setClientId($identifier);
        $client->setClientSecret($this->generateSecret());
        $client->setRedirectUri($redirect_uris);
        $client->setGrantTypes($grant_types);

        // Verify scopes
        foreach ($scopes as $scope) {
            // Get Scope
            $scopeObject = $this->sm->findScopeByScope($scope);
            if (!$scopeObject) {
                throw new ScopeNotFoundException();
            }
        }

        $client->setScopes($scopes);

        // Store Client
        $this->em->persist($client);
        $this->em->flush();

        return $client;
    }
1207422
protected function registerDefaultGrant($name)
    {
        // PascalCase the grant. E.g: 'authorization_code' becomes 'AuthorizationCode'
        $class = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $name)));
        $class = 'League\\OAuth2\\Client\\Grant\\' . $class;

        $this->checkGrant($class);

        return $this->setGrant($name, new $class);
    }
1035104
public function create($userId, $name, $redirect, $personalAccess = false, $password = false)
    {
        $client = (new Client)->forceFill([
            'user_id' => $userId,
            'name' => $name,
            'secret' => str_random(40),
            'redirect' => $redirect,
            'personal_access_client' => $personalAccess,
            'password_client' => $password,
            'revoked' => false,
        ]);

        $client->save();

        return $client;
    }
175318
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
    {
        $query = null;

        if (!is_null($redirectUri) && is_null($clientSecret)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        } elseif (!is_null($clientSecret) && is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_clients.name as name')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret);
        } elseif (!is_null($clientSecret) && !is_null($redirectUri)) {
            $query = $this->getConnection()->table('oauth_clients')
                   ->select(
                       'oauth_clients.id as id',
                       'oauth_clients.secret as secret',
                       'oauth_client_endpoints.redirect_uri as redirect_uri',
                       'oauth_clients.name as name')
                   ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
                   ->where('oauth_clients.id', $clientId)
                   ->where('oauth_clients.secret', $clientSecret)
                   ->where('oauth_client_endpoints.redirect_uri', $redirectUri);
        }

        if ($this->limitClientsToGrants === true && !is_null($grantType)) {
            $query = $query->join('oauth_client_grants', 'oauth_clients.id', '=', 'oauth_client_grants.client_id')
                   ->join('oauth_grants', 'oauth_grants.id', '=', 'oauth_client_grants.grant_id')
                   ->where('oauth_grants.id', $grantType);
        }

        $result = $query->first();

        if (is_null($result)) {
            return;
        }

        return $this->hydrateEntity($result);
    }
256727
private function createRoute(Redirect $redirect)
    {
        return new Route(
            $redirect->getOrigin(), array(
                    '_controller' => 'FrameworkBundle:Redirect:urlRedirect',
                    'path' => $redirect->getTarget(),
                    'permanent' => $redirect->isPermanent(),
                ));
    }
1049239
public function loginPage($redirect, $identification = null)
    {
        $preAuthCode = $this->createPreAuthCode($identification);

        // 拼接出微信公众号登录授权页面url
        return sprintf(self::COMPONENT_LOGIN_PAGE, $this->appid, $preAuthCode, urlencode($redirect));
    }
535056
public function lock($name, $seconds = 0, $owner = null)
    {
        return new RedisLock($this->connection(), $this->prefix.$name, $seconds, $owner);
    }
750188
public function grantToUser( $rightId, $userId, $grant = true )
    {
        return $this->grant(
            $this->sql( $this->getTableInSchema( 'user_right_x_user' ) ),
            array(
                'rightId'   => $rightId,
                'userId'    => $userId,
            ),
            $grant
        );
    }
389856
public function redirect()
    {
        $state = null;

        if ($this->usesState()) {
            $this->request->session()->put('state', $state = $this->getState());
        }

        return new RedirectResponse($this->getAuthUrl($state));
    }
136833
public function create(Redirect &$redirect)
    {
        $endpoint = '/admin/redirects.json';
        $data = $redirect->exportData();
        $response = $this->request(
            $endpoint, "POST", array(
            'redirect' => $data
            )
        );
        $redirect->setData($response['redirect']);
    }
960647
public function update(Client $client, $name, $redirect)
    {
        $client->forceFill([
            'name' => $name, 'redirect' => $redirect,
        ])->save();

        return $client;
    }
802657
protected function createPasswordClient(ClientRepository $clients)
    {
        $name = $this->option('name') ?: $this->ask(
            'What should we name the password grant client?',
            config('app.name').' Password Grant Client'
        );

        $client = $clients->createPasswordGrantClient(
            null, $name, 'http://localhost'
        );

        $this->info('Password grant client created successfully.');

        $this->outputClientDetails($client);
    }
332388
private function getRedirect($currentRoute, $redirect = false)
    {
        $useRedirect = $this->options->getUseRedirectParameterIfPresent();
        $routeExists = ($redirect && $this->routeExists($redirect));
        if (!$useRedirect || !$routeExists) {
            $redirect = false;
        }

        switch ($currentRoute) {
            case 'zfcuser/login':
            case 'scn-social-auth-user/login':
            case 'scn-social-auth-user/register':
            case 'scn-social-auth-user/authenticate/provider':
            case 'scn-social-auth-user/add-provider/provider':
                $route = ($redirect) ?: $this->options->getLoginRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            case 'zfcuser/logout':
            case 'scn-social-auth-user/logout':
                $route = ($redirect) ?: $this->options->getLogoutRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            default:
                return $this->router->assemble(array(), array('name' => 'zfcuser'));
        }
    }
319037
public function grantToUser( $rightId, $userId, $grant = true )
    {
        return $this->getMapper()
                    ->grantToUser( $rightId, $userId, $grant );
    }
104639
public function buildHttpRedirect($userAgent, array $get, array $cookie)
    {
        $settingsManager = new Shopgate_Helper_Redirect_SettingsManager($this->config, $get, $cookie);
        $templateParser  = new Shopgate_Helper_Redirect_TemplateParser();

        $linkBuilder = new Shopgate_Helper_Redirect_LinkBuilder(
            $settingsManager,
            $templateParser
        );

        $redirector = new Shopgate_Helper_Redirect_Redirector(
            $settingsManager,
            new Shopgate_Helper_Redirect_KeywordsManager(
                $this->buildMerchantApi(),
                $this->config->getRedirectKeywordCachePath(),
                $this->config->getRedirectSkipKeywordCachePath()
            ),
            $linkBuilder,
            $userAgent
        );

        return new Shopgate_Helper_Redirect_Type_Http($redirector);
    }