默认情况下,通过电子邮件发送到电子邮件的密码重置令牌不同于保存到数据库的密码。我已经使用Hasher::make()
和hash_hmac('sha256', $token, env('APP_KEY'))
对其进行了哈希处理,然后将该令牌与数据库进行比较,但是无效。我应该怎么做才能将通过电子邮件发送的令牌转换为数据库令牌或进行比较?
我也尝试过
public function convertToken($token)
{
if (Str::startsWith($key = env('APP_KEY'), 'base64:')) {
$key = base64_decode(substr($key, 7));
}
return hash_hmac('sha256', $token, $key);
}
答案 0 :(得分:0)
Laravel默认实现使用的Hasher可以通过
检索import { reducer as formReducer } from 'redux-form';
const addressReducerPlugin = (state, action) => {
switch (action.type) {
case CHANGE:
return action.meta.field !== 'country'
? state
: { ...state, values: { ...state.values, state: '' } };
default:
return state;
}
};
export default formReducer.plugin({
[SHIPPING_ADDRESS_FORM_NAME]: addressReducerPlugin,
});
然后您可以对令牌进行哈希处理,如下所示:
/opt/libreoffice6.2/program/oosplash: /lib64/libz.so.1: version `ZLIB_1.2.3.4' not found (required by /opt/libreoffice6.2/program/oosplash)
/opt/libreoffice6.2/program/oosplash: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/libreoffice6.2/program/oosplash)
/opt/libreoffice6.2/program/oosplash: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /opt/libreoffice6.2/program/libuno_sal.so.3)
/opt/libreoffice6.2/program/oosplash: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /opt/libreoffice6.2/program/libuno_sal.so.3)
您可以使用以下代码将令牌与数据库中存储的值进行比较:
$hasher = Password::broker()->getRepository()->getHasher();
但是您为什么要实现自己的Laravel团队已经完成的工作?除非您这样做很有趣,否则最好使用Laravel默认身份验证。