php - 数据库中的电子邮件列被加密时无法发送密码重置电子邮件(Laravel 8)
问题描述
我还没有找到解决这个问题的方法:在数据库中的电子邮件列被加密时发送密码重置电子邮件失败(Laravel 8 .57.0 with JetStream、Fortify、Livewire)。我浏览了其他一些问答,但它们主要是针对 Laravel 5 的,恐怕它们并不完全兼容。
开始了:
用户表中的某些列使用 betterapp/laravel-db-encrypter ( https://github.com/betterapp/laravel-db-encrypter ) 加密 - 包括电子邮件列。有一个单独的用户名字段用于登录(主要是出于安全原因)。
Fortify 路由被禁用,我在 routes/web.php 上维护它们。
config/auth.php 文件有
'username' => 'username',
'email' => 'email'
重置密码视图会导致 Laravel\Fortify\Http\Controllers 中的 PasswordResetLinkController,它具有以下功能:
public function store(Request $request): Responsable
{
$request->validate([Fortify::email() => 'required|email']);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = $this->broker()->sendResetLink(
$request->only(Fortify::email())
);
dd($status); // -> "passwords.user"
return $status == Password::RESET_LINK_SENT
? app(SuccessfulPasswordResetLinkRequestResponse::class, ['status' => $status])
: app(FailedPasswordResetLinkRequestResponse::class, ['status' => $status]);
}
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
protected function broker(): PasswordBroker
{
return Password::broker(config('fortify.passwords'));
}
(Fortify::email() 获取 config/fortify -> 'email' 中的设置。)
sendResetLink() 函数位于 PasswordBroker 接口中:
<?php
namespace Illuminate\Contracts\Auth;
use Closure;
interface PasswordBroker
{
/**
* Constant representing a successfully sent reminder.
*
* @var string
*/
const RESET_LINK_SENT = 'passwords.sent';
/**
* Constant representing a successfully reset password.
*
* @var string
*/
const PASSWORD_RESET = 'passwords.reset';
/**
* Constant representing the user not found response.
*
* @var string
*/
const INVALID_USER = 'passwords.user';
/**
* Constant representing an invalid token.
*
* @var string
*/
const INVALID_TOKEN = 'passwords.token';
/**
* Constant representing a throttled reset attempt.
*
* @var string
*/
const RESET_THROTTLED = 'passwords.throttled';
/**
* Send a password reset link to a user.
*
* @param array $credentials
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null);
/**
* Reset the password for the given token.
*
* @param array $credentials
* @param \Closure $callback
* @return mixed
*/
public function reset(array $credentials, Closure $callback);
这个:public function sendResetLink(array $credentials, Closure $callback = null);
该函数接收凭据 *),但无法检索正确的电子邮件,因为它已在数据库中加密。该函数给了我一个结果“passwords.user” [用 dd($status);] 检查了资源/lang/en/passwords -> 'user' => “我们找不到用户那个电子邮件地址。” 并以该错误返回resetlinkpage。
如果我只是从电子邮件列中删除加密,密码重置效果很好。
想法和问题:
*) 什么证书?在这种情况下的电子邮件?如果我先用电子邮件地址检索它,我可以将其更改为其他内容,例如用户名吗?我错过了什么吗?
我该如何解决这个问题,或者我应该放弃这种情况并将我的设置更改回未加密的电子邮件列?用散列电子邮件创建另一列并与第一列进行比较有什么用处?
我被困住了。我需要其他双眼睛和更多的大脑。请帮忙!
解决方案
推荐阅读
- ios - UINavigationBar(嵌入在 UIImagePickerController 中)背景颜色未更新仅在 iOS13 中发生的此问题
- android - kotlin 是否有用于从两种不同类型的列表中获取公共数据的高阶函数?
- javascript - 如何在axios中添加拦截器功能?
- ios - 当我从 Scheme Url(Swift 项目)启动应用程序时未调用 openURL
- javascript - 在这个 jQuery 验证案例中,如何避免重复 isValid?
- typescript - 如何在打字稿中分配通用条件推断类型的值?
- python - 用 Selenium python 中的 bb 代码填充 textarea
- python - 如何从pyqt5中的父MainWindow类继承自我
- angular - HeaderComponent.logout2 处未定义的属性“注销”
- javascript - 在 Angular 6 应用程序中通过 javascript 更改 base64 图像大小并使用不同的扩展名(png、jpg、gif 等)下载