Store a new client.

@param  int  $userId
@param  string  $name
@param  string  $redirect
@param  bool  $personalAccess
@param  bool  $password
@return \Laravel\Passport\Client
172894
public function create($userId, $name, $redirect, $personalAccess = false, $password = false)
    {
        $client = Passport::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;
    }
745332
public function store(Request $request)
    {
        $user = new \App\User();

        $user->email = $request->email;
        $user->name = $request->name;
        $user->password = Hash::make($request->password);

        $user->save();

        return redirect('scaffold-users');
    }
1237856
public function setUserId( $userId )
    {
        $this->_user    = null;
        $this->userId   = ( (int) $userId ) ?: null;
        return $this;
    }
261132
public function usingCredentials($name = null)
    {
        // Set credentials name.
        $this->getAccessManager()->setCredentialsName($name)->setCredentials($name);

        // Return this.
        return $this;
    }
255834
protected function createRequest($client, $userId, $request, array $scopes)
    {
        return (new ServerRequest)->withParsedBody(
            ['grant_type' => 'password',
            'client_id' => $client->id,
            'client_secret' => $client->secret,
            'username' => $request->get('email'),
            'password' => $request->get('password'),
            'user_id' => $userId,
            'scope' => implode(' ', $scopes)]
        );
    }
369060
public function store(Request $request, $user_id)
    {
    	$user = User::findOrFail($user_id);
		
		if (isset($request->permission_id) && count($request->permission_id))
		{
			$user->permissions()->sync($request->permission_id);
		}
		else
		{
			$user->permissions()->sync(array());
		}
		$user->save();
		
		return redirect(url("/user/$user_id/permission"))->with('dp_announce', trans('deeppermission.alert.user_permission.updated'));
    }
1103118
public function createPersonalAccessClient($userId, $name, $redirect)
    {
        return $this->create($userId, $name, $redirect, true);
    }
1333416
static function loadProvider($key, $redirect) {
    if (!$redirect) {
      throw new \InvalidArgumentException("No redirect provided.");
    }

    switch ($key) {
      case "google":
        return new GoogleWithOpenID(array(
          'clientId' =>\Openclerk\Config::get("oauth2_google_client_id"),
          'clientSecret' => \Openclerk\Config::get("oauth2_google_client_secret"),
          'redirectUri' => $redirect,
          'scopes' => array('email', 'openid'),
          'openid.realm' => \Openclerk\Config::get('openid_host'),
        ));

      case "facebook":
        return new \League\OAuth2\Client\Provider\Facebook(array(
          'clientId' =>\Openclerk\Config::get("oauth2_facebook_app_id"),
          'clientSecret' => \Openclerk\Config::get("oauth2_facebook_app_secret"),
          'redirectUri' => $redirect,
          'scopes' => array('email'),
        ));

      case "github":
        return new \League\OAuth2\Client\Provider\Github(array(
          'clientId' =>\Openclerk\Config::get("oauth2_github_client_id"),
          'clientSecret' => \Openclerk\Config::get("oauth2_github_client_secret"),
          'redirectUri' => $redirect,
          'scopes' => array('email'),
        ));

      default:
        throw new UserAuthenticationException("No such known OAuth2 provider '$key'");
    }
  }
981580
protected function createAuthCodeClient(ClientRepository $clients)
    {
        $userId = $this->option('user_id') ?: $this->ask(
            'Which user ID should the client be assigned to?'
        );

        $name = $this->option('name') ?: $this->ask(
            'What should we name the client?'
        );

        $redirect = $this->option('redirect_uri') ?: $this->ask(
            'Where should we redirect the request after authorization?',
            url('/auth/callback')
        );

        $client = $clients->create(
            $userId, $name, $redirect
        );

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

        $this->outputClientDetails($client);
    }
366930
public function storeAccessToken($userId, AccessToken $accessToken)
    {
        self::requireSession();
        $_SESSION[\sprintf('_oauth2_token_%s', $userId)][] = $accessToken;
    }
1354828
public function store(CreateRedirectRequest $request)
    {
        $this->authorize(RedirectsPolicy::PERMISSION_CREATE);

        $redirect = Redirect::createRedirect(
            $request->getValidatedData()
        );

        $this->transNotification('created', [], $redirect->toArray());

        return redirect()->route('admin::seo.redirects.show', [$redirect]);
    }
161627
public function setAccessToken($token, $clientId, $userId, $expiryTimestamp, $scope = null)
    {
        $authTokenDataMapper = $this->getTokenDataMapper(Entity\AccessToken::class);

        $client = $this->getClientDataMapper()->findByUuid($clientId);

        if (! $accessToken = $authTokenDataMapper->findByToken($token)) {
            $accessToken = new Entity\AccessToken(null, $token, $client);
        } else {
            $accessToken->setClient($client);
        }

        if ($userId) {
            $user = $this->getUserDataMapper()->findByUuid($userId);

            if ($user instanceof $this->userClass) {
                $accessToken->setUser($user);
            }
        }

        $expiryDate = is_int($expiryTimestamp) ? new DateTime('@' . $expiryTimestamp) : null;
        $accessToken->setExpiryDate($expiryDate);

        if ($scope) {
            $scopes = $this->getScopeDataMapper()->findScopes(explode(' ', $scope));
            $accessToken->setScopes($scopes);
        }

        $authTokenDataMapper->save($accessToken);
    }
1086023
public function store(StoreUserPost $request)
    {
        $model = (new Services\UsersService)->dataInsert($request->all());
        $route = config('acl.routes.users.index');
        return redirect()->route($route)->with('success', "Usuário(a) '{$model->name}' foi criado com sucesso");
    }
395545
public function store(CreateUserRequest $request, User $user)
    {
        $this->authorize(UsersPolicy::PERMISSION_CREATE);

        $user->fill($request->getValidatedData());
        $user->is_active = true;
        $user->save();
        $user->roles()->sync($request->get('roles'));

        $this->transNotification('created', ['name' => $user->full_name], $user->toArray());

        return redirect()->route('admin::auth.users.index');
    }
1275416
public function setClientUser($client_id, $user_id)
    {
        if ($this->getClientUser($client_id, $user_id)) {
            return true;
        } else {
            $created_at = date('Y-m-d H:i:s');
            $sql        = 'INSERT INTO %s (client_id, user_id, created_at) VALUES (:client_id, :user_id, :created_at)';
            $sql        = sprintf($sql, $this->config['client_user_table']);

            $params = array_map('trim', compact('client_id', 'user_id', 'created_at'));

            return $this->db->prepare($sql)->execute($params);
        }
    }
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);
    }
491751
public function store($name = null)
    {
        if (is_null($name)) {
            $name = $this->defaultStore;
        }

        if (isset($this->caches[$name])) {
            return $this->caches[$name];
        }

        $config = config('cache.stores.' . $name);
        if ($config === null) {
            throw new InvalidArgumentException('Cache store "' . $name . '" is not defined.');
        }

        if (!isset($config['driver'])) {
            throw new InvalidArgumentException('Cache driver for store "' . $name . '" is not specified.');
        }

        switch ($config['driver']) {
            case 'APCu':
                $provider = new ApcuCache;
                break;
            case 'Array':
                $provider = new ArrayCache;
                break;
            case 'File':
                $provider = new FilesystemCache($config['path']);
                break;
            case 'Memcached':
                $memcached = new Memcached();
                $memcached->addServer($config['host'], $config['port'], $config['weight']);
                $provider = new MemcachedCache();
                $provider->setMemcached($memcached);
                break;
            case 'Redis':
                $redis = new Redis;
                $redis->connect($config['host'], $config['port'], $config['timeout']);
                $provider = new RedisCache;
                $provider->setRedis($redis);
                break;
            default:
                throw new InvalidArgumentException('Cache driver "' . $config['driver'] . '" is not supported.');
        }

        return $this->caches[$name] = new Cache($provider);
    }