私は最終的にすべての作業を得ました。
// Stormpath user account creation
\Stormpath\Client::$apiKeyProperties = "apiKey.id="
.env('STORMPATH_CLIENT_APIKEY_ID').
"\napiKey.secret=".env('STORMPATH_CLIENT_APIKEY_SECRET');
$client = \Stormpath\Client::getInstance();
$apps = $client->tenant->applications;
$apps->search = array('name' => 'My Application');
$application = $apps->getIterator()->current();
$account = \Stormpath\Resource\Account::instantiate(
[
'givenName' => $request->input('username'),
'middleName' => '',
'surname' => 'StromTrooper',
'username' => $request->input('username'),
'email' => $request->input('user_mail'),
'password' => $request->input('user_pass'),
'confirmPassword' => $request->input('user_pass')
]
);
// Create User Account and Log-in the User
try
{
$response = $application->createAccount($account);
$passwordGrant = new \Stormpath\Oauth\PasswordGrantRequest(
$request->input('user_mail'),
$request->input('user_pass')
);
$auth = new \Stormpath\Oauth\PasswordGrantAuthenticator($application);
$result = $auth->authenticate($passwordGrant);
$atoken = cookie("access_token",
$result->getAccessTokenString(),
$result->getExpiresIn()
);
$rtoken = cookie("refresh_token",
$result->getRefreshTokenString(),
$result->getExpiresIn()
);
$response_bag['success'] = url('userprofile');
}
catch (\Stormpath\Resource\ResourceError $re)
{
$response_bag['error'] = $re->getMessage();
$atoken = 'null';
$rtoken = 'null';
}
return response()
->json($response_bag)
->withCookie($atoken)
->withCookie($rtoken);
@brettererありがとうとユーザーコントローラに私がapp('stormpath.user');
を使用して、ユーザーの詳細情報にアクセスすることができると私はLaravel 5.1
を使用していたので、私は機能public function isAuthenticated(Request $request)
から
vendor/stormpath/laravel/src/Http/Middleware/Authenticate.php
から
$token = $request->bearerToken();
をコメントアウトしなければなりませんでした
私は 'access_token'をクッキーに設定することができますが、ミドルウェア( 'stormpath.auth')をユーザルートに添付すると'未定義メソッドを呼び出す\ Http \ Request :: bearerToken() 'が得られます – linktoahref
Laravelのどのバージョンを使用していますか? – bretterer
私の 'composer.json'に' 5.1。* 'が表示されます。ah https:// laravel.com/api/5.1/Illuminate/Http/Request.htmlの' bearerToken() 'が見つかりません。 – linktoahref