我是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. 不要允许用户多次登录
- 2. Facebook PHP SDK不允许登录用户
- 3. 不吸引活跃用户的用户登录信息
- 4. 烧瓶登录不会拒绝不活跃的用户
- 5. 仅限Facebook登录按钮(不允许新用户登录)
- 6. 让用户活跃/不活跃php mysql
- 7. 只允许在用户登录
- 8. 允许用户登录使用不同的表中的数据
- 9. Django:不允许用户在未登录时看到页面
- 10. 检测,如果Facebook的用户使用登录按钮允许或不允许登录
- 11. laravel 4只允许登录用户浏览该网站
- 12. 网址不允许:Facebook的PHP登录
- 13. 允许在登录时仅登录一个用户
- 14. CakePHP的Auth->允许不允许的行为没有登录
- 15. 如何让用户创建新用户并允许在Laravel中登录?
- 16. 安全登录,不允许用户使用URL导航
- 17. 只允许用户使用Google登录是否不好?
- 18. 允许root用户登录ftp
- 19. 允许Wordpress用户多登录
- 20. 登录表单:不允许重定向到允许的页面
- 21. T-SQL创建用户/登录不允许连接
- 22. Python社会认证:Google登录错误(用户不允许)
- 23. 用户登录安全。 Session vs Mysql活跃用户表
- 24. Wix不允许用户覆盖目录
- 25. Laravel 5.1用户登录不起作用
- 26. 火力地堡不允许Facebook登录
- 27. Spring Oauth2登录 - 匿名不允许?
- 28. 发布时不允许登录
- 29. PostgreSQL:角色不允许登录
- 30. 错误的登录系统,不会允许登录