如何在Laravel 4中匹配输入密码和数据库哈希密码 [英] How to match input password and database hash password in laravel 4

查看:67
本文介绍了如何在Laravel 4中匹配输入密码和数据库哈希密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过Laravel中的给定请求对用户密码进行身份验证?如何对照数据库中存储的密码哈希检查密码?

How to authenticate a user password from a given request in Laravel? How is the password checked against the password hash stored in the database?

推荐答案

首先,您需要根据电子邮件地址或用户名找到正在登录的用户,或者您要识别它们,例如:

First, you'll need to find the User who is logging in based on email address or username or however you identify them, for example:

$user = User::where('email', '=', 'email@address.com')->first();

然后,您需要像这样检查散列密码:

Then, you'll need to CHECK the hashed password, like so:

Hash::check('INPUT PASSWORD', $user->password);

这将根据密码是否匹配返回true或false.

This will return true or false based on whether or not the password matches.

这篇关于如何在Laravel 4中匹配输入密码和数据库哈希密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆