当前位置: 首页>>代码示例>>PHP>>正文


PHP PassHash::hash方法代码示例

本文整理汇总了PHP中PassHash::hash方法的典型用法代码示例。如果您正苦于以下问题:PHP PassHash::hash方法的具体用法?PHP PassHash::hash怎么用?PHP PassHash::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PassHash的用法示例。


在下文中一共展示了PassHash::hash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderContent

 protected function renderContent()
 {
     if (!user()->isGuest) {
         $model = new UserChangePassForm();
         // if it is ajax validation request
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'userchangepass-form') {
             echo CActiveForm::validate($model);
             Yii::app()->end();
         }
         // collect user input data
         if (isset($_POST['UserChangePassForm'])) {
             $model->attributes = $_POST['UserChangePassForm'];
             // validate user input password
             if ($model->validate()) {
                 $u = User::model()->findbyPk(user()->id);
                 if ($u !== null) {
                     $u->password = PassHash::hash($model->new_password_1);
                     if ($u->save()) {
                         user()->setFlash('success', t('cms', 'Changed Password Successfully!'));
                     }
                 }
                 $model = new UserChangePassForm();
             }
         }
         $this->render('cmswidgets.views.user.user_change_pass_widget', array('model' => $model));
     } else {
         Yii::app()->request->redirect(user()->returnUrl);
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:29,代码来源:UserChangePassWidget.php

示例2: createUserByUsernameAndPassword

 /**
  * Creating new user via Email
  * @param String $name User full name
  * @param String $password User login password
  */
 public function createUserByUsernameAndPassword($name, $password)
 {
     require_once 'PassHash.php';
     $response = array();
     // First check if user already existed in db
     if (!$this->userExistsByEmail($email)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // here you would generate other user's properties, like alias
         // default avatar, api_key for authentication, and insert it in the DB.
         $usercreationsucceed = true;
         // Check for successful insertion
         if ($usercreationsucceed) {
             // User successfully inserted
             // here you should return USER_CREATED_SUCCESSFULLY;
             return "user created with name: " . $name . ", password: " . $password;
         } else {
             // Failed to create user
             return USER_CREATION_FAILED;
         }
     } else {
         // User with same email already existed in the db
         return USER_ALREADY_EXISTED;
     }
     return $response;
 }
开发者ID:UFOkechukwu,项目名称:SocialLoginForiOS,代码行数:31,代码来源:OAuthHelper.php

示例3: createUser

 /**
  * Creating new user
  * @param String $name User full name
  * @param String $email User login email id
  * @param String $password User login password
  */
 public function createUser($name, $email, $password)
 {
     require_once 'PassHash.php';
     $response = array();
     // First check if user already existed in db
     if (!$this->isUserExists($email)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // Generating API key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare("INSERT INTO users(name, email, password_hash, api_key, status) values(?, ?, ?, ?, 1)");
         $stmt->bind_param("ssss", $name, $email, $password_hash, $api_key);
         $result = $stmt->execute();
         $stmt->close();
         // Check for successful insertion
         if ($result) {
             // User successfully inserted
             return USER_CREATED_SUCCESSFULLY;
         } else {
             // Failed to create user
             return USER_CREATE_FAILED;
         }
     } else {
         // User with same email already existed in the db
         return USER_ALREADY_EXISTED;
     }
     return $response;
 }
开发者ID:amakaroff82,项目名称:mimi,代码行数:35,代码来源:DbHandler.php

示例4: createUser

 /**
  * Creating new user
  * @param String $name User full name
  * @param String $email User login email id
  * @param String $password User login password
  */
 public function createUser($name, $email, $password, $comp)
 {
     require_once 'PassHash.php';
     $response = array();
     // First check if user already existed in db
     if (!$this->isUserExists($email)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // Generating API key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare("INSERT INTO il_user(name, email, password_hash, api_key, status,il_company_acc) values(?, ?, ?, ?, 1,?)");
         $stmt->bind_param("sssss", $name, $email, $password_hash, $api_key, $comp);
         $result = $stmt->execute();
         $stmt->close();
         // Check for successful insertion
         if ($result) {
             // User successfully inserted
             return $result;
         } else {
             // Failed to create user
             return 0;
         }
     } else {
         // User with same email already existed in the db
         return 2;
     }
     return $response;
 }
开发者ID:ars0709,项目名称:restlog,代码行数:35,代码来源:db_user.php

示例5: registerAppUser

 public function registerAppUser($params)
 {
     require_once 'PassHash.php';
     $name = $params['name'];
     $email = $params['email'];
     $gcm_registration_id = $params['gcm_registration_id'];
     $password = $params['password'];
     $notify_app_status = $params['notify_app_status'];
     $send_email_status = $params['send_email_status'];
     $response = array();
     // First check if user already existed in db
     if (!$this->isUserExists($email)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // Generating API key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare("INSERT INTO app_users (name, email, password_hash, api_key, app_notify_status, send_email_status, gcm_registration_id, edited_at) values(?, ?, ?, ?, ?, ?, ?, date('Y-m-d H:i:s'))");
         $stmt->bind_param("ssssiis", $name, $email, $password_hash, $api_key, $notify_app_status, $send_email_status, $gcm_registration_id);
         $result = $stmt->execute();
         $stmt->close();
         // Check for successful insertion
         if ($result) {
             return USER_CREATED_SUCCESSFULLY;
         } else {
             return USER_CREATE_FAILED;
         }
     } else {
         return USER_ALREADY_EXISTED;
     }
     return $response;
 }
开发者ID:umarmansuri,项目名称:quotes-everyday-api,代码行数:32,代码来源:DbHandler.php

示例6: createUser

 /**
  * Creating new user
  * @param String $name User full name
  * @param String $email User login email id
  * @param String $password User login password
  */
 public function createUser($name, $email, $password, $gender)
 {
     require_once 'PassHash.php';
     // First check if user already existed in db
     if (!$this->isUserExists($email)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // Generating API key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare('INSERT INTO `users`(`name`, `email`, `gender`, `password_hash`, `key`)
                                      VALUES(:name, :email, :gender, :password_hash, :key)');
         $stmt->execute(array('name' => $name, 'email' => $email, 'gender' => $gender, 'password_hash' => $password_hash, 'key' => $api_key));
         // Check for successful insertion
         if ($stmt->rowCount() > 0) {
             // User successfully inserted
             return USER_CREATED_SUCCESSFULLY;
         } else {
             // Failed to create user
             return USER_CREATE_FAILED;
         }
     } else {
         // User with same email already existed in the db
         return USER_ALREADY_EXISTED;
     }
 }
开发者ID:AmrN,项目名称:Event-Sched---PHP,代码行数:32,代码来源:DbHandler.php

示例7: renderContent

 protected function renderContent()
 {
     $user_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if ($user_id !== 0) {
         $model = User::model()->findbyPk($user_id);
         $old_pass = (string) $model->password;
         // if it is ajax validation request
         if (isset($_POST['ajax']) && $_POST['ajax'] === 'userupdate-form') {
             echo CActiveForm::validate($model);
             Yii::app()->end();
         }
         // collect user input data
         if (isset($_POST['User'])) {
             $model->attributes = $_POST['User'];
             if ($model->password != $old_pass) {
                 $model->password = PassHash::hash($model->password);
             }
             $model->scenario = 'update';
             if ($model->save()) {
                 user()->setFlash('success', t('cms', 'Updated Successfully!'));
             }
         }
         $this->render('cmswidgets.views.user.user_update_widget', array('model' => $model));
     } else {
         throw new CHttpException(404, t('cms', 'The requested page does not exist.'));
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:27,代码来源:UserUpdateWidget.php

示例8: inserirUsuario

 /**
  * Inserir o usuário.
  * @param type $usuario
  */
 public function inserirUsuario($usuario, $tipoUsuario)
 {
     //caso usuário não seja criado o valor 0 será atribuído
     $cdUsuario = ID_NAO_RETORNADO;
     if (!$this->ehUsuarioExistente($usuario->login)) {
         // Caso o usuário não exista será construída o Insert na tb_usuario.
         $stmt = $this->conn->prepare("INSERT INTO tb_usuario(nm_login, " . "nm_senha, nm_apikey, nm_usuario, dt_nascimento," . " nm_sexo, cd_tipousuario, fl_ativo)" . " values(?, ?, ?, ?, ?, ?, " . $tipoUsuario . ", " . USUARIO_ATIVO . ")");
         $nascimento = $data = implode("-", array_reverse(explode("/", $usuario->nascimento)));
         $sexo = strtoupper($usuario->sexo);
         $passwordHash = PassHash::hash($usuario->senha);
         $apiKey = $this->gerarApiKey();
         // Parâmetros: tipos das entradas, entradas.
         $stmt->bind_param("ssssss", $usuario->login, $passwordHash, $apiKey, $usuario->nome, $nascimento, $sexo);
         // Executar a consulta.
         $result = $stmt->execute();
         if ($result) {
             $cdUsuario = $stmt->insert_id;
         }
         $stmt->close();
     } else {
         // Código para usuário já existente.
         $cdUsuario = USUARIO_EXISTENTE;
     }
     return $cdUsuario;
 }
开发者ID:joseilsonjunior,项目名称:nutrif,代码行数:29,代码来源:DbHandler.php

示例9: createUser

 public function createUser($firstName, $secondName, $userName, $eMail, $birthDate, $sex, $password)
 {
     require_once 'PassHash.php';
     $response = array();
     // First check if user already existed in db
     if (!$this->isUserExists($userName)) {
         // Generating password hash
         $password_hash = PassHash::hash($password);
         // Generating API key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare("INSERT INTO users(first_name, second_name, user_name, email, password_hash, api_key, birthdate, sex) \n            \t\tvalues(?, ?, ?, ?, ?, ?, ?, ?)");
         $stmt->bind_param("sssssssi", $firstName, $secondName, $userName, $eMail, $password_hash, $api_key, $birthDate, $sex);
         $result = $stmt->execute();
         $stmt->close();
         // Check for successful insertion
         if ($result) {
             // User successfully inserted
             $response['message'] = USER_CREATED_SUCCESSFULLY;
             $response['api_key'] = $api_key;
         } else {
             // Failed to create user
             $response['message'] = USER_CREATE_FAILED;
             $response['api_key'] = 'no key';
         }
     } else {
         // User with same username already existed in the db
         $response['message'] = USER_ALREADY_EXIST;
         $response['api_key'] = 'no key';
     }
     return $response;
 }
开发者ID:ugeHidalgo,项目名称:SportLogServer,代码行数:32,代码来源:UserDbHandler.php

示例10: createUser

 /**
  * Creating new user
  * @param String $name User full name
  * @param String $email User login email id
  * @param String $password User login password
  */
 public static function createUser($objUser)
 {
     if (User::where('email', $objUser['email'])->count() == 0) {
         $user = User::create(array('username' => $objUser['username'], 'password' => PassHash::hash($objUser['password']), 'email' => $objUser['email'], 'type' => 2, 'startDate' => date('Y-m-d'), 'lastLogin' => date('Y-m-d'), 'apiKey' => $this->generateApiKey()));
         $result = $user->save();
         //= 1 success
         if ($result) {
             return USER_CREATED_SUCCESSFULLY;
         } else {
             return USER_CREATE_FAILED;
         }
     } else {
         return USER_ALREADY_EXISTED;
     }
 }
开发者ID:TrienDo,项目名称:BestBooks,代码行数:21,代码来源:UserService.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     //
     $user = User::find($id);
     if ($user) {
         if ($request->get('password')) {
             $user->pass_hash = PassHash::hash($request->get('password'));
         }
         if ($request->get('email')) {
             $user->email = $request->get('email');
         }
         if ($request->get('sdt')) {
             $user->sdt = $request->get('sdt');
         }
         $user->save();
         return response()->json(array('error' => false, 'message' => 'User Updated'));
     } else {
         return response()->json(array('error' => true, 'message' => 'User Not Found'));
     }
 }
开发者ID:nhattrungluu,项目名称:laravel,代码行数:27,代码来源:UserController.php

示例12: createUser

 public function createUser($login, $password)
 {
     require_once 'PassHash.php';
     $response = array();
     if (!$this->isUserExists($login)) {
         $password_hash = PassHash::hash($password);
         $user_key = $this->generateApiKey();
         $money = 0;
         $stmt = $this->conn->prepare("INSERT INTO profile(login, password, money, user_key) values(?, ?, ?, ?)");
         $stmt->bind_param("ssis", $login, $password_hash, $money, $user_key);
         $result = $stmt->execute();
         $stmt->close();
         if ($result) {
             return USER_CREATED_SUCCESSFULLY;
         } else {
             return USER_CREATE_FAILED;
         }
     } else {
         return USER_ALREADY_EXISTED;
     }
     return $response;
 }
开发者ID:Reigninwild,项目名称:RIW-Service,代码行数:22,代码来源:DbHandler.php

示例13: createUser

 public function createUser($user)
 {
     require_once 'PassHash.php';
     $username = $user['username'];
     $email = $user['email'];
     $password = $user['password'];
     // Generating password hash
     $password_hash = PassHash::hash($password);
     // insert query
     $stmt = $this->conn->prepare("INSERT INTO users(username, email, password_hash) values(?, ?, ?)");
     $stmt->bind_param("sss", $username, $email, $password_hash);
     $result = $stmt->execute();
     $stmt->close();
     // Check for successful insertion
     if ($result) {
         // User successfully inserted
         return USER_CREATED_SUCCESSFULLY;
     } else {
         // Failed to create user
         return USER_CREATE_FAILED;
     }
 }
开发者ID:jiaweizhang,项目名称:lumivote.com,代码行数:22,代码来源:DbHandler.php

示例14: createUser

 public function createUser($first_name, $last_name, $email, $user_name, $password)
 {
     //Get pass hash script
     require_once 'PassHash.php';
     //create an array for response return
     $response = array();
     //First check to see if user already exists (via email)
     if (!$this->isUserExists($email)) {
         //user account does not exist - create it
         //Make a hashed password based on user inputted password
         $password_hash = PassHash::hash($password);
         //make user activation code
         $active = md5(uniqid(rand(), true));
         //prepare insert statement
         $stmt = $this->conn->prepare("INSERT INTO user    \n    (first_name, last_name, email, user_name, password, date_expires, active)\n    VALUES (:fname, :lname, :email, :uname, :password, SUBDATE(NOW(), INTERVAL 1 DAY), :active)");
         $stmt->bindValue(':email', $email, PDO::PARAM_STR);
         $stmt->bindValue(':password', $password_hash, PDO::PARAM_STR);
         $stmt->bindValue(':fname', $first_name, PDO::PARAM_STR);
         $stmt->bindValue(':lname', $last_name, PDO::PARAM_STR);
         $stmt->bindValue(':uname', $user_name, PDO::PARAM_STR);
         $stmt->bindValue(':active', $active, PDO::PARAM_STR);
         $result = $stmt->execute();
         //check for success|failure
         if ($result) {
             //success
             $response['message'] = 'USER_SUCCESSFULLY_CREATED';
             $response['active'] = $active;
         } else {
             //failure
             $response['message'] = 'USER_CREATE_FAILED';
         }
     } else {
         //user account already exists - return message
         $response['message'] = 'USER_ALREADY_EXISTS';
     }
     //RETURN FINAL RESPONSE
     return $response;
 }
开发者ID:clarktk,项目名称:bingetunes,代码行数:38,代码来源:DbHandler.php

示例15: createUser

 public function createUser($name, $email, $password)
 {
     require_once 'PassHash.php';
     $response = [];
     // check if user email alrready exists
     if ($this->isUserExists($email)) {
         return USER_ALREADY_EXISTED;
     } else {
         // generate password hash
         $password_hash = PassHash::hash($password);
         // generate api key
         $api_key = $this->generateApiKey();
         // insert query
         $stmt = $this->conn->prepare("INSERT INTO user_regular \n                (name, email, password_hash, api_key)\n                VALUES (?, ?, ?, ?);");
         $stmt->bind_param("ssss", $name, $email, $password_hash, $api_key);
         $result = $stmt->execute();
         if ($result) {
             return USER_CREATED_SUCCESSFULLY;
         } else {
             return USER_CREATED_FAILED;
         }
     }
     return $response;
 }
开发者ID:adib2149,项目名称:PHP_SLIM_RESTfulAPI_tv-series-manager,代码行数:24,代码来源:DbHandler.php


注:本文中的PassHash::hash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。