本文整理汇总了PHP中Hash::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::check方法的具体用法?PHP Hash::check怎么用?PHP Hash::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
if (Auth::check()) {
echo json_encode(array('succcess' => false, 'state' => 200, 'errMsg' => array('inputMsg' => '该用户已登录,请不要重复登录'), 'no' => 2));
exit;
}
$account = Input::get('user_email');
$password = Input::get('user_psw');
$rememberMe = Input::get('user_remember');
$captcha = Input::get('user_auth');
$ip = $this->getIP();
$codeKey = md5($ip);
$captchaCode = Cache::tags('register', 'code')->get($codeKey);
if ($captcha != $captchaCode) {
echo json_encode(array('success' => false, 'state' => 200, 'errMsg' => array('inputMsg' => '验证码验证失败'), 'no' => 1));
exit;
}
$accountCheck = $this->accountCheck($account);
if (!is_object($accountCheck)) {
echo json_encode(array('success' => false, 'state' => 200, 'errMsg' => array('inputMsg' => '用户不存在'), 'no' => 1));
exit;
}
$passwordCheck = Hash::check($password, $accountCheck->user->password);
if ($passwordCheck) {
if ($rememberMe == 'true') {
Auth::login($accountCheck, true);
} else {
Auth::login($accountCheck);
}
} else {
echo json_encode(array('succcess' => false, 'state' => 200, 'errMsg' => array('inputMsg' => '密码验证失败'), 'no' => 2));
}
echo json_encode(array('success' => true, 'state' => 200, 'nextSrc' => url('usercenter')));
}
示例2: login
public function login()
{
$validaciones = Usuario::validacioneslogin(Input::all());
if ($validaciones->fails()) {
return Redirect::to('/')->withErrors($validaciones)->withInput();
} else {
$email = Input::get('email');
$clave = Input::get('clave');
$usuario = Usuario::where('login', '=', $email)->get();
// no se hace new xq necesitamos la misma instancia
if ($usuario->count() == 1) {
if (Hash::check($clave, $usuario[0]->clave)) {
Session::put('id', $usuario[0]->id);
Session::put('nombre', $usuario[0]->nombre);
Session::put('login', $usuario[0]->login);
Session::put('email', $usuario[0]->email);
Session::put('rol', $usuario[0]->rol);
Session::put('estatus', $usuario[0]->estatus);
Session::put('logged', TRUE);
//MANDA una variable q indica logeado
Session::put('familia_id', $usuario[0]->familia->id);
return Redirect::to('/dashboard');
} else {
Session::flash('message', 'La clave no es válida');
Session::flash('class', 'danger');
}
} else {
Session::flash('message', 'El Usuario no está registrado');
Session::flash('class', 'danger');
}
return Redirect::to('/');
}
}
示例3: postConfirmation
/**
* Handle a POST request to remind a user of their password.
*
* @return Response
*/
public function postConfirmation()
{
// 3 error cases - user already confirmed, email does not exist, password not correct
// (prevents people from brute-forcing email addresses to see who is registered)
$email = Input::get('email');
$password = Input::get('password');
$user = User::where('email', $email)->first();
if (!isset($user)) {
return Response::json($this->growlMessage('That email does not exist.', 'error'), 400);
}
if (empty($user->token)) {
return Response::json($this->growlMessage('That user was already confirmed.', 'error'), 400);
}
if (!Hash::check($password, $user->password)) {
return Response::json($this->growlMessage('The password for that email is incorrect.', 'error'), 400);
}
$token = $user->token;
$email = $user->email;
$fname = $user->fname;
//Send email to user for email account verification
Mail::queue('email.signup', array('token' => $token), function ($message) use($email, $fname) {
$message->subject('Welcome to the Madison Community');
$message->from('sayhello@opengovfoundation.org', 'Madison');
$message->to($email);
});
return Response::json($this->growlMessage('An email has been sent to your email address. Please follow the instructions in the email to confirm your email address before logging in.', 'warning'));
}
示例4: add
/**
* Add a menu item
*
* @param string $path dot separated path in the array.
* @param array $options menu options array
* @return void
*/
public static function add($menu, $path, $options = array())
{
// Juggle argument for backward compatibility
if (is_array($path)) {
$options = $path;
$path = $menu;
$menu = self::activeMenu();
} else {
self::activeMenu($menu);
}
$pathE = explode('.', $path);
$pathE = array_splice($pathE, 0, count($pathE) - 2);
$parent = join('.', $pathE);
if (!empty($parent) && !Hash::check(self::$_items[$menu], $parent)) {
$title = Inflector::humanize(end($pathE));
$o = array('title' => $title);
self::_setupOptions($o);
self::add($parent, $o);
}
self::_setupOptions($options);
$current = Hash::extract(self::$_items[$menu], $path);
if (!empty($current)) {
self::_replace(self::$_items[$menu], $path, $options);
} else {
self::$_items[$menu] = Hash::insert(self::$_items[$menu], $path, $options);
}
}
示例5: postChangePwd
public function postChangePwd()
{
$response = array();
// 获取所有表单数据
$data = Input::all();
$user = User::where('id', '=', Auth::id())->first();
// 验证旧密码
if (!Hash::check($data['old_password'], $user->password)) {
$response['success'] = false;
$response['message'] = '原始密码错误';
return Response::json($response);
}
// 创建验证规则
$rules = array('password' => 'alpha_dash|between:6,16|confirmed');
// 自定义验证消息
$messages = array('password.alpha_dash' => '密码格式不正确。', 'password.between' => '密码长度请保持在:min到:max位之间。', 'password.confirmed' => '两次输入的密码不一致。');
// 开始验证
$validator = Validator::make($data, $rules, $messages);
if ($validator->passes()) {
// 验证成功
// 更新用户
$user->setPasswordAttribute($data['password']);
if ($user->save()) {
$response['success'] = true;
$response['message'] = '密码修改成功';
} else {
$response['success'] = false;
$response['message'] = '密码修改失败';
}
} else {
$response['success'] = false;
$response['message'] = $validator->errors->first();
}
return Response::json($response);
}
示例6: attempt
/**
* Attempt to log a user into the application.
*
* @param array $arguments
* @return void
*/
public function attempt($arguments = array())
{
$username = Config::get('auth.username');
if (!Config::has('auth.username')) {
throw new Exception('The username in application/config/auth.php must be defined.');
}
$model = Config::get('auth.model');
// Add the username to the query
$query = array('$or' => array(array(Config::get('auth.username') => $arguments[Config::get('auth.username')])));
// If we've specified an 'username_alt' field in the config, add that to the $OR
if (Config::has('auth.username_alt')) {
$query['$or'][] = array(Config::get('auth.username_alt') => $arguments[Config::get('auth.username')]);
}
$user = Epic_Mongo::db('user')->findOne($query);
// This driver uses a basic username and password authentication scheme
// so if the credentials match what is in the database we will just
// log the user into the application and remember them if asked.
$password = $arguments[Config::get('auth.password')];
// if ( ! is_null($user) and Hash::check($password, $user->password))
if (!is_null($user) and Hash::check($password, $user->password)) {
return $this->login($user->_id, array_get($arguments, 'remember'));
} else {
if (!is_null($user) and md5($password) == $user->password) {
return $this->login($user->_id, array_get($arguments, 'remember'));
}
}
return false;
}
示例7: changePass
public function changePass()
{
$id = Input::get('id');
$opass = Input::get('old_password');
$npass = Input::get('new_password');
$input = Input::all();
$rules = array('old_password' => 'required|min:1|max:50', 'new_password' => 'required|min:1|max:50');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
$error_messages = $validator->messages();
$error_response = array('error' => array('message' => $error_messages->first(), 'type' => 'Exception', 'code' => 425));
return Response::json($error_response, 425)->setCallback(Input::get('callback'));
} else {
$user = User::find($id);
if ($user) {
if (Hash::check($opass, $user->password)) {
$npass = Hash::make($npass);
User::find($id)->update(array('password' => $npass));
return "Password Changed.";
} else {
$error_response = array('error' => array('message' => "Wrong Old Password", 'type' => 'Exception', 'code' => 425));
return Response::json($error_response, 425)->setCallback(Input::get('callback'));
}
}
}
}
示例8: authKeyCheck
public function authKeyCheck($authKey)
{
if (empty($this->authKey)) {
return false;
}
return \Hash::check($authKey . \Config::get('schauth::config.salt.password'), $this->authKey);
}
示例9: compute
public function compute($data, $delete = false)
{
$id = $this->getID();
foreach ($this->autoFields as $autoField) {
$values = [];
$unsetDepends0 = [];
foreach ($autoField['depends0'] as $depend) {
if (Hash::check($data, $depend)) {
$values[$depend] = Hash::get($data, $depend);
} else {
if (is_array($this->data) && Hash::check($this->data, $depend)) {
$values[$depend] = Hash::get($this->data, $depend);
} else {
$unsetDepends0[] = $depend;
}
}
}
if (!empty($unsetDepends0)) {
$data = $this->find('first', ['conditions' => [$this->name . '.id' => $id], 'fields' => $unsetDepends0, 'recursive' => 0]);
foreach ($unsetDepends0 as $depend) {
$values[$depend] = Hash::get($data, $depend);
}
}
foreach ($autoField['depends1'] as $modelName => $depends) {
if (!is_string($modelName) || empty($depends)) {
continue;
}
$model = $this->{$modelName};
$data = $this->{$modelName}->find('all', ['conditions' => [$modelName . '.' . Inflector::underscore($this->name) . '_id' => $id], 'fields' => $depends, 'recursive' => 0]);
$values[$modelName] = Hash::extract($data, '{n}.' . $modelName);
}
$this->set($autoField['name'], call_user_func($autoField['callback'], Hash::expand($values)));
}
}
示例10: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
\Validator::extend('current_password', function ($attribute, $value, $parameters, $validator) {
return \Hash::check($value, \Auth::user()->password);
});
}
开发者ID:elNapoli,项目名称:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代码行数:12,代码来源:AppServiceProvider.php
示例11: postAjaxLogin
public function postAjaxLogin()
{
try {
if (!isset($_POST)) {
throw new Exception('Request error');
}
$id = \Input::get('id', false);
$passwd = \Input::get('password', false);
if (!$id || !$password) {
throw new Exception('Parameter error');
}
$m = \Member::where('uid', '=', md5($id))->where('social', '=', 'rebeauty')->get();
if ($m == null) {
throw new Exception('Not founded');
}
if (!\Hash::check($passwd, $m->password)) {
throw new Exception('帳號或密碼錯誤');
}
// register user into Auth that is a global variable
\Auth::login($m);
return \Redirect::route('frontend.index');
} catch (Exception $e) {
return Response::json(array('status' => 'error', 'message' => $e->getMessage(), '_token' => csrf_token()));
}
}
示例12: beforeValidate
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from Model::save().
* @return bool True if validate operation should continue, false to abort
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
* @see Model::save()
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function beforeValidate($options = array())
{
// ウィザード画面中はstatusチェックをしないでほしいので
// ここに来る前にWorkflowBehaviorでつけられたstatus-validateを削除しておく
if (Hash::check($options, 'validate') == RegistrationsComponent::REGISTRATION_VALIDATE_TYPE) {
$this->validate = Hash::remove($this->validate, 'status');
}
$this->validate = Hash::merge($this->validate, array('block_id' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'on' => 'update')), 'title' => array('rule' => 'notBlank', 'message' => sprintf(__d('net_commons', 'Please input %s.'), __d('registrations', 'Title')), 'required' => true, 'allowEmpty' => false), 'answer_timing' => array('publicTypeCheck' => array('rule' => array('inList', array(RegistrationsComponent::USES_USE, RegistrationsComponent::USES_NOT_USE)), 'message' => __d('net_commons', 'Invalid request.')), 'requireOtherFields' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.answer_start_period', 'Registration.answer_end_period'), 'OR'), 'message' => __d('registrations', 'if you set the period, please set time.'))), 'answer_start_period' => array('checkDateTime' => array('rule' => 'checkDateTime', 'message' => __d('registrations', 'Invalid datetime format.'))), 'answer_end_period' => array('checkDateTime' => array('rule' => 'checkDateTime', 'message' => __d('registrations', 'Invalid datetime format.')), 'checkDateComp' => array('rule' => array('checkDateComp', '>=', 'answer_start_period'), 'message' => __d('registrations', 'start period must be smaller than end period'))), 'is_key_pass_use' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.')), 'requireOtherFieldsKey' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('AuthorizationKey.authorization_key'), 'AND'), 'message' => __d('registrations', 'if you set the use key phrase period, please set key phrase text.')), 'authentication' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.is_image_authentication'), 'XOR'), 'message' => __d('registrations', 'Authentication key setting , image authentication , either only one can not be selected.'))), 'is_image_authentication' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.')), 'authentication' => array('rule' => array('requireOtherFields', RegistrationsComponent::USES_USE, array('Registration.is_key_pass_use'), 'XOR'), 'message' => __d('registrations', 'Authentication key setting , image authentication , either only one can not be selected.'))), 'is_answer_mail_send' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'is_regist_user_send' => array('boolean' => array('rule' => array('boolean'), 'message' => __d('net_commons', 'Invalid request.'))), 'reply_to' => array('email' => array('rule' => array('email', false, null), 'message' => sprintf(__d('mails', '%s, please enter by e-mail format'), __d('mails', 'E-mail address to receive a reply')), 'allowEmpty' => true))));
parent::beforeValidate($options);
// 最低でも1ページは存在しないとエラー
if (!isset($this->data['RegistrationPage'][0])) {
$this->validationErrors['pickup_error'] = __d('registrations', 'please set at least one page.');
} else {
// ページデータが存在する場合
// 配下のページについてバリデート
$validationErrors = array();
$maxPageIndex = count($this->data['RegistrationPage']);
$options['maxPageIndex'] = $maxPageIndex;
foreach ($this->data['RegistrationPage'] as $pageIndex => $page) {
// それぞれのページのフィールド確認
$this->RegistrationPage->create();
$this->RegistrationPage->set($page);
// ページシーケンス番号の正当性を確認するため、現在の配列インデックスを渡す
$options['pageIndex'] = $pageIndex;
if (!$this->RegistrationPage->validates($options)) {
$validationErrors['RegistrationPage'][$pageIndex] = $this->RegistrationPage->validationErrors;
}
}
$this->validationErrors += $validationErrors;
}
// 引き続き登録フォーム本体のバリデートを実施してもらうためtrueを返す
return true;
}
示例13: getUserByCredential
/**
* @param $password
* @param $loginName
* @param bool $flag
* @return Users
*/
public function getUserByCredential($password, $loginName, $flag = null)
{
if ($flag == null) {
$flag = false;
}
\Debugbar::info($flag);
// TODO: Implement getUserByCredential() method.
if (!$flag) {
$user = $this->model->newQuery()->with('getGroup')->where('email', '=', $loginName)->where('ugroup', '!=', 2)->where('Active', '=', 1)->first();
if ($user != null) {
if (\Hash::check($password, $user->getPassword())) {
\Debugbar::addMessage('hash matches - ' . Hash::make($password));
return $user;
} else {
\Debugbar::addMessage('hash dose not match');
return null;
}
} else {
return null;
}
} else {
$user = $this->model->newQuery()->with('getGroup')->where('Password', '=', $password)->where('email', '=', $loginName)->where('Active', '=', 1)->first();
if ($user != null) {
return $user;
} else {
return null;
}
}
}
示例14: changePassword
public function changePassword($id)
{
/*ERROR
0 - Something went wrong
1 - success
2 - wrong password
3 - password mismatch
*/
$i = Input::all();
if (Hash::check($i['password'], Auth::user()->password)) {
if ($i['newPassword'] == $i['confirmPassword']) {
$u = User::where('id', Auth::id())->first();
if (!empty($u)) {
$u->password = Hash::make($i['newPassword']);
if ($u->save()) {
$a = new Activity();
$a->actor = Auth::id();
$a->location = 1;
$a->logs = 'Updated password.';
$a->save();
return '1';
} else {
return '0';
}
} else {
return '0';
}
} else {
return '3';
}
} else {
return '2';
}
//return $i;
}
示例15: login
public function login()
{
$email = Input::get('email');
$password = Input::get('password');
$user = Users::where('email', '=', $email)->first();
if ($user != null && Hash::check($password, $user->password)) {
Session::set('logged', true);
Session::set('email', $email);
Session::set('time_zone', $user->time_zone);
Session::set('lid', $user->language_id);
Session::set('user_id', $user->id);
$userRole = Roles::getUserRole($user->role_id);
Session::set('role', $userRole);
// getting car_id if its a driver
if ($user->role_id == Roles::DRIVER_ROLE_ID) {
$driver = Driver::where('user_id', '=', $user->id)->firstOrFail();
Session::set('car_id', $driver->car_id);
}
$result = array('success' => true, 'message' => 'logged in successfully', 'payload' => array('role' => $userRole));
} else {
Session::flush();
$result = array('success' => false, 'message' => 'invalid email or password');
}
return $result;
}