php - 如何在 JWT API - Laravel 5.8 上验证用户群?
问题描述
我在 Laravel 5.8 上使用 PHP 7.2。
我目前使用 Laravel 附带的身份验证提供程序来登录我的用户。
它当前检查配置的数据库中的电子邮件和密码是否匹配。
我做了这个
$dbAuth = Auth::attempt(array(
'email' => $email,
'password' => $password
));
if ($dbAuth) {
return Redirect::to('/dashboard')->with('success', 'You have been successfully logged in.');
} else {
return Redirect::to('/')->with('error', 'Username/Password Wrong')->with('email', $email)->withErrors($validator);
}
我不能再这样做了,我必须调用一个返回令牌的 API。
只是为了澄清:
我的主要目标是调用 JWT API,并在收到 200 响应时让我的用户登录。
我的用户现在如何登录?
解决方案
I would recommend you use this package for JWT auth, it has a good documentation as well.
推荐阅读
- ionic-framework - ionic5 发布后创建 ionic4 项目
- php - 当我使用 Ajax 调用时,选择选择器不显示
- c++ - 如何将数据存储到动态数组中
- php - 在 Laravel 中处理多个 smtps 的入站邮件(接收电子邮件)
- android - 列表视图中的颤振列表视图不滚动
- python-3.x - AttributeError:“NoneType”对象没有“读取”属性。如何解决此错误?
- machine-learning - 我们如何将 XGBOOST 模型与密集神经网络堆叠在一起
- mysql - 使用三表主 sku 表查找未列出的项目,已售出,未售出
- sql-server - 有没有办法在sql server中获取触发器ID?
- amazon-web-services - 关于扩展 REST API 的概念问题