public function postSignUp() { $data = \Data::post()->all(); $UserDataModel = new \App\data_model\User($data); if (!$UserDataModel->verify()) { \Session::setFlash('signup-data', $UserDataModel->getData()); \Session::setFlash('signup-errors', $UserDataModel->getErrors()); } else { $UserRecord = new \App\record\User($data); $UserRecord['password'] = \Crypt::hash($UserRecord['password']); $UserRecord['created_on_date'] = array('raw' => 'NOW()'); $UserRecord->insert(); \App::with('User')->sendActivationEmail($UserRecord['id']); \Session::setFlash('signup-success', 1); } //el \View::redirect('/signup'); }
public function postEditPassword() { $data = \Data::post(array('password_current', 'password', 'password_verify')); $UserDataModel = new \App\data_model\User($data); $current_password = \App::with('User')->User->select('password')->where('id=?', \App::with('User')->userId())->first()['password']; if (\Crypt::hash($data['password_current']) != $current_password) { \Session::setFlash('edit-password-errors', array('password_current' => 'That wasn\'t your current password')); } else { if (!$UserDataModel->verifySetData()) { \Session::setFlash('edit-password-errors', $UserDataModel->getErrors()); } else { \App::with('User')->changePassword($UserDataModel['password']); \Session::setFlash('edit-success', 'Password Updated!'); } } //el \View::redirect('/user/edit'); }
/** * Sets the password for the user * * @param string $password * @param string $algorithm * @param array $options [optional] */ public function setPassword($password, $algorithm = PasswordFile::ALG_MD5, array $options = null) { $this->hash = Crypt::hash($password, $algorithm, $options); }
public function createAuthCode() { // Save random auth code in users meta data $authcode = Crypt::hash("random:authcode:" . DateManager::now() . ":" . rand()); Meta::remove("user", $this->id, "authcode"); Meta::save("user", $this->id, "authcode", Crypt::createHash($authcode)); }
/** * Change the current users password. * * @param string $password The new password. * @param int $user_id The id of the user. * * @return boolean */ public function changePassword($password, $user_id = null) { if ($user_id === null) { $user_id = $this->userId(); } //if return $this->User->update(array('password' => \Crypt::hash($password)))->where('id=?', $user_id)->finalize(); }