- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
你如何告诉 laravel auth::attempt
密码字段以明文形式存储而不是假设它是散列的?
在 guard.php 中
public function attempt(array $credentials = array(), $remember = false, $login = true)
{
$this->fireAttemptEvent($credentials, $remember, $login);
$user = $this->provider->retrieveByCredentials($credentials);
// If an implementation of UserInterface was returned, we'll ask the provider
// to validate the user against the given credentials, and if they are in
// fact valid we'll log the users into the application and return true.
if ($user instanceof UserInterface)
{
if ($this->provider->validateCredentials($user, $credentials))
{
if ($login) $this->login($user, $remember);
return true;
}
}
return false;
}
或者更好的是,我将只有 2 列,一列作为明文,另一列作为 password_secured。
如果我尝试后者,我如何告诉尝试密码列名称是 password_secured.
因为我尝试了这个,但得到了一个错误 Undefined index: password
。
$user = array(
'user_id' => Input::get('username'),
'password_secured' => Input::get('password'),
'checklogin' => 0,
);
if (Auth::attempt($user)) {
return 'login success';
}
问题是我正在移植应用程序,而不是从头开始构建,我确实需要以明文形式存储密码,因为另一个应用程序正在使用数据库(并且它是实时的)并且被编码为读取密码明文。
最佳答案
考虑运行一个脚本来散列所有密码:绝不应该强制甚至考虑以明文形式存储(即使您继承了系统),因为这些密码是一旦您的数据库内容泄露,立即丢失。黑客攻击发生了。想象一下,如果您的客户发现您没有按照标准处理他们的数据,将会面临怎样的诉讼......
现在,假设您不想理会这个警告,那么这样做的方法虽然有点老套,但确实有效。 Guard
,从来源(查找__construct
)来看,被赋予一个实现UserProviderInterface
的对象。
你有一堆合适的对象。选择一个你想要的,然后扩展它。我们会从 DatabaseUserProvider
中获得一些乐趣,尽管这种扩展方法很方便并且对所有这些方法都可行。
我们要扩展的方法是public function validateCredentials(UserInterface $user, array $credentials)
。如下:
namespace Illuminate\Auth;
class MyUserInterface extends DatabaseUserProvider {
public function validateCredentials(UserInterface $user, array $credentials) {
$plain = $credentials['password'];
return ($plain === $user->getAuthPassword());
}
}
由于 MyUserInterface
扩展了本身提供 UserProviderInterface
的 DatabaseUserProvider
,MyUserInterface
现在可以依赖注入(inject)到 中Guard
作为提供者。我们已经完成了一半的工作。下一步是实际告诉 Guard 加载你的东西。我不熟悉 Laravel4 加载 Guard
实现的方式,但是在配置的某个地方,您可以将 MyUserInterface
设置为选择的 Guard 接口(interface)。我不能比这更具体了。
顺便说一句,该类需要与 Auth
的其他接口(interface)实现位于同一位置。
关于php - laravel 4 auth::attempt 明文密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16793333/
尝试从对话框中的 EditText 获取 Edit Text 的值,但一次又一次地出现此错误 Attempt to invoke virtual method 'android.text.Editab
最近尝试了一下最新的Laravel(6.4)。正在尝试实现基于 API 的简单登录功能。没有使用 Passport 或 Tymon 的 JWT 等任何软件包。我使用了非常基本的身份验证(只需在用户表中
最近尝试了一下最新的Laravel(6.4)。正在尝试实现基于 API 的简单登录功能。没有使用 Passport 或 Tymon 的 JWT 等任何软件包。我使用了非常基本的身份验证(只需在用户表中
我在我的 PC 上运行 cifar10 网络,在完成训练和运行评估脚本后出现以下错误: 2016-06-01 14:37:14.238317: precision @ 1 = 0.000 Traceb
我正在使用 ng2-toastr 并收到以下错误 https://www.npmjs.com/package/ng2-toastr Attempt to use a destroyed view: d
env file:环境文件: APP_ENV=localAPP_DEBUG=trueAPP_KEY= ...........DB_HOST=srv3.linuxisrael.co.ilDB_D
当我登录管理员时,我正在尝试对 api 进行多重保护身份验证,我得到了跟随错误 BadMethodCallException Method Illuminate\Auth\Req uestGuard:
我开始在 Lua 中进行编程,并在运行脚本时出现此错误: attempt to index upvalue 'base' (a function value) 这可能是因为我还没有掌握一些非常基本的东
我试图在 Oozie 工作流中聚合一些数据。但是聚合步骤失败。 我在日志中发现了两个兴趣点:第一个是一个似乎重复出现的错误(?): 容器完成后,它会被杀死,但会以非零退出代码 143 退出。 它完成了
我的问题是当我调用函数时: [self performSegueWithIdentifier: @"FinalPlayPT" sender: self]; 它有效,但我有这个警告: Warning:
项目背景 项目整体采用的是springboot+mybatis 方式。有一次做数据查询的时候。console突然报:DataIntegrityViolationException: Error att
我在使用 Jobs 发送电子邮件的 Ubuntu Server 上设置了 Laravel 项目。 下面是我在 中的 laravel-worker 文件/etc/supervisor/laravel-w
尝试运行我的 React 应用程序时收到以下错误: ./src/components/App/App.js Attempted import error: 'combineReducers' is n
我的编码功能是这样的: fn encode_login(packet: &str) { let bytes = packet.as_bytes(); for (i, &element)
如果一个版本号大于另一个版本号,我的 msbuild 需要采取有条件的操作。我尝试像下面这样编写代码,但发现出现错误(也在下面)。我哪里出错了?
我是 Lua 的新手,并试图让事情在我的脑海中进行排序。我试过这个代码: function newCarousel(images) local slideToImage = function(
我正在使用 entrust用于在 Laravel 5.3 中管理基于角色的权限,并自然地为不同的用户类型使用手动/自定义登录。 Auth::attempt()可以吗?处理外表关系?基本上,我想做这样的
我谷歌了一遍又一遍,但没有对我有用的信息。 情况是这样的:1.产品有 active 。2.我通过测试账号来测试我的apk。3.我已经上传了一整天的apk。 但是当我想为应用程序中的项目付款时,goog
我正在尝试使用 groovy 解析日期字符串,但遇到了问题。这是字符串的样子和不起作用的逻辑。 def dateString = "2017-01-01T12:00:00Z" def date = D
我正在使用 ParseFacebookUtils 从 Facebook 登录我的应用。 LoginActivity 的 onCreate: protected void onCreate(Bundle
我是一名优秀的程序员,十分优秀!