我們這個項目進(jìn)行了半年了,以前沒問題,上周六開始所有接口就提示 ,
項目信息:
laravel5.5,前臺使用控制器加載頁面(return view()),后臺使用iview-admin,node做服務(wù)器請求laravel的api.php 中的接口;前臺頁面中獲取登錄信息正常;登錄功能是采用了oAuth登錄了集團(tuán)平臺。
為了確保后端邏輯也實際業(yè)務(wù)沒有問題,貼出在blade模板中的php代碼
<script type="text/javascript">
<?php
$user = \Auth::user();
$contact = new ArrayObject();
if ($user) {
$user->setVisible([
'user_id',
'username',
'name',
'avatar'
]);
// 對應(yīng)的聯(lián)系人
$_contact = $user->contact();
if ($_contact) {
$_contact->setVisible([
'contact_id',
'name',
'is_admin',
'is_sub_admin'
]);
$contact = $_contact->toArray();
} else {
}
$user = $user->toArray();
} else {
$user = new ArrayObject();
}
$corp = \XXH::corp();
if ($corp) {
$corp->setVisible([
'corp_id',
'user_id',
'logo',
'name',
'type',
'code'
]);
$corp = $corp->toArray();
} else {
$corp = new ArrayObject();
}
$data = [
'baseUrl' => url('/'),
'state' => [
'user' => $user,
'contact' => $contact,
'corp' => $corp
],
];
echo 'window.XXH = ' . json_encode($data);
?>
</script>
以下是輸出:
報錯詳細(xì)信息
"exceptions": {
"count": 1,
"exceptions": [
{
"type": "Illuminate\\Auth\\AuthenticationException",
"message": "Unauthenticated.",
"code": 0,
"file": "D:\\jeff\\code\\jianwen\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
"line": 66,
"surrounding_lines": [
" }\n",
" }\n",
"\n",
" throw new AuthenticationException('Unauthenticated.', $guards);\n",
" }\n",
"}\n"
],
"xdebug_link": null
}
]
},
應(yīng)對回答者的需要,貼出auth代碼
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
// jhc 修改
'driver' => 'passport',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| JUser Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,//jhc 修改
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
// jhc 添加
'agent' => [
'agent_id' => env('AUTH_AGENT_ID', ''),
'redirect_url' => env('AUTH_REDIRECT_URL', ''),
'platform_url' => env('AUTH_PALTFORM_URL', ''),
'gateway_url' => env('AUTH_GATEWAY_URL', ''),
'corp_user_api' => 'auth_user',
'corp_token_api' => 'corp_tokens',
'corp_info' => 'auth_corp',
'token' => env('AUTH_TOKEN', ''),
'encoding_key' => env('AUTH_ENCODING_KEY', '')
],
];
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。