我是Laravel的新手,我已經爲用戶完成了一個系統。驗證用戶是通過「php artisan make:auth」完成的,我在users
表中有一列名爲activated
;當activated = 0
,我不希望用戶登錄。請給我一點幫助?對不起,如果這個線索很無聊。不允許不活躍的用戶在Laravel登錄
-1
A
回答
-1
我發現我自己,我只需添加這myLoginController.php
protected function credentials(Request $request)
{
$credentials = $request->only($this->username(), 'password');
$credentials['activated'] = 1;
return $credentials;
}
0
你將要處理這既爲使用AuthenticatesUsers
性狀或您AuthController
手動一部分通過檢查你的登錄表單響應並返回適當的迴應:
<?php
namespace App\Http\Controllers;
use App;
use Illuminate\Auth\AuthManager;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
/**
* Class AuthController
* @package Speechlink\Http\Controllers\Auth
*/
class AuthController extends Controller
{
use AuthenticatesUsers;
/**
* Create a new authentication controller instance.
* @param AuthManager $auth
*/
public function __construct(AuthManager $auth)
{
$this->auth = $auth;
}
/**
* Deal with the login attempt (overrides the trait's postLogin method)
*
* @param Request $request
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function postLogin(Request $request)
{
$this->validate($request, [
'username' => 'required',
'password' => 'required',
]);
$credentials = $request->only('username', 'password');
if ($this->auth->attempt($credentials)) {
// We authenticated so continue
return redirect('path/to/logged_in');
} else {
// We failed authentication so redirect somewhere else
return redirect('path/to/disabled_user');
}
}
}
相關問題
- 1. Facebook PHP SDK不允許登錄用戶
- 2. 不吸引活躍用戶的用戶登錄信息
- 3. 燒瓶登錄不會拒絕不活躍的用戶
- 4. 僅限Facebook登錄按鈕(不允許新用戶登錄)
- 5. Laravel 5.4,當用戶不活躍時顯示錯誤消息auth登錄
- 6. 檢測,如果Facebook的用戶使用登錄按鈕允許或不允許登錄
- 7. 允許在登錄時僅登錄一個用戶
- 8. 只允許用戶使用Google登錄是否不好?
- 9. 允許root用戶登錄ftp
- 10. 允許Wordpress用戶多登錄
- 11. 登錄表單:不允許重定向到允許的頁面
- 12. Python社會認證:Google登錄錯誤(用戶不允許)
- 13. T-SQL創建用戶/登錄不允許連接
- 14. 用戶登錄安全。 Session vs Mysql活躍用戶表
- 15. 火力地堡不允許Facebook登錄
- 16. Spring Oauth2登錄 - 匿名不允許?
- 17. 發佈時不允許登錄
- 18. Wix不允許用戶覆蓋目錄
- 19. Laravel 5.1用戶登錄不起作用
- 20. 允許在Laravel 5.4中使用用戶名或電子郵件登錄
- 21. Mysql:找到每週登錄一次的活躍用戶
- 22. jenkins不允許登錄,登錄頁面重新出現
- 23. Laravel 5.4,顯示錯誤消息AUTH登錄時,用戶使用缺省auth不活躍
- 24. 如何允許匿名訪問者,但不允許在ASP.NET MVC 5中的操作方法登錄用戶?
- 25. 如何在Laravel 5.4中允許基於角色的登錄?
- 26. IAM:CloudFormation:GetTemplateSummary不被用戶允許
- 27. setTimeout函數,如果用戶不活躍
- 28. VBA不活躍
- 29. 允許登錄用戶在PHP下載文件否則沒有人不能
- 30. QPainter的不活躍