private function __change_password() { require_once 'clinique_change_password.php'; $email = required_param('email', PARAM_EMAIL); $old_password = required_param('old_pwd', PARAM_RAW); $new_password = required_param('new_pwd', PARAM_RAW); ChangePassword::__getPassword($email, $old_password, $new_password); }
public function __getPassword($username, $email, $old_password, $new_password) { global $CFG, $DB; $systemcontext = context_system::instance(); $response = new CliniqueServiceResponce(); if (!empty($username) && !empty($old_password) && !empty($new_password)) { $user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0, 'suspended' => 0)); if (!empty($user)) { if (is_mnet_remote_user($user)) { add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - mnet user trying to access.', 0, $user->id); $response->response(true, 'cp_mnet_user'); die; } if (isguestuser($user)) { add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - guest user credential supplied.', 0, $user->id); $response->response(true, 'cp_guest'); die; } // make sure user is allowed to change password require_capability('moodle/user:changeownpassword', $systemcontext, $user->id); // $generatePasswordResult = generatePassword::app_validate_internal_user_password($user, $old_password); if (!ChangePassword::__app_validate_internal_user_password($user, $old_password)) { $response->response(true, 'cp_wrong_oldpwd'); } else { $userauth = get_auth_plugin($user->auth); if ($userauth->user_update_password($user, $new_password)) { unset_user_preference('auth_forcepasswordchange', $user); unset_user_preference('create_password', $user); $response->response(false, 'cp_success'); } else { add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Change password - password change updation failure.', 0, $user->id); $response->response(true, 'cp_failure'); } } } else { $response->response(false, 'cp_no_mail_record'); } } else { add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Change password - input parameters missing.', 0, $user->id); } }
* Change the password of a given user * * @file * @ingroup Maintenance * * @author Ævar Arnfjörð Bjarmason <*****@*****.**> * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ $optionsWithArgs = array('user', 'password'); require_once 'commandLine.inc'; $USAGE = "Usage: php changePassword.php [--user=user --password=password | --help]\n" . "\toptions:\n" . "\t\t--help show this message\n" . "\t\t--user the username to operate on\n" . "\t\t--password the password to use\n"; if (in_array('--help', $argv)) { wfDie($USAGE); } $cp = new ChangePassword(@$options['user'], @$options['password']); $cp->main(); /** * @ingroup Maintenance */ class ChangePassword { var $dbw; var $user, $password; function ChangePassword($user, $password) { global $USAGE; if (!strlen($user) or !strlen($password)) { wfDie($USAGE); } $this->user = User::newFromName($user);
<?php ini_set('display_errors', 1); error_reporting(E_ALL); require_once 'controller/user-db-config.php'; require_once 'controller/class_change_Password.php'; $change = new ChangePassword($DB_con); if (isset($_POST['do_change'])) { $old = $_POST['current']; $new = password_hash($_POST['new'], PASSWORD_DEFAULT); //echo $change->verifyPassword($old); $chk = $change->verifyPassword($old); //echo $chk['Password']; if ($old == $chk['Password']) { $change->change_password($old, $new); } else { $error = "Could not find the current password entered!"; } } ?> <div class="container"> <div class="row"> <div class="col-xs-12 col-md-4 col-md-offset-4 form-in-out"> <form method="post"> <div class="page-header"> <h2 class="form-signin-heading">Change Password</h2> </div><?php // Error message display on fail if (isset($error)) { ?>
$strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23); $strPassword = sha1($strSalt . $pw); $objUser = UserModel::findByPk($this->User->id); $objUser->pwChange = ''; $objUser->password = $strPassword . ':' . $strSalt; $objUser->save(); Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']); $this->redirect('contao/main.php'); } } $this->reload(); } $this->Template->theme = $this->getTheme(); $this->Template->messages = Message::generate(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']); $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet']; $this->Template->action = ampersand(Environment::get('request')); $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['pw_change']; $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']); $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0]; $this->Template->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0]; $this->Template->output(); } } /** * Instantiate the controller */ $objChangePassword = new ChangePassword(); $objChangePassword->run();
public function actionChangePassword() { $transaction = Yii::app()->db->beginTransaction(); try { $model = new ChangePassword(); if (isset($_POST['ChangePassword'])) { $model->attributes = $_POST['ChangePassword']; if ($model->save()) { $this->audit->logAudit(Yii::app()->user->id, new DateTime(), AppConstants::AUDIT_OBJECT_USER, AppConstants::AUDIT_OPERATION_CHANGE_PASSWORD, Yii::app()->user->id); $this->render('/site/successfullOperation', array('header' => 'Contraseña modificada con éxito', 'message' => 'Haga click en volver para regresar a Mi Perfil', 'returnUrl' => Yii::app()->createUrl('user/myProfile'))); $transaction->commit(); return; } else { $transaction->rollback(); } } $this->render('changePassword', array('model' => $model)); } catch (Exception $exc) { Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR); $transaction->rollback(); } }
<?php include_once '../AutoLoader.php'; AutoLoader::registerDirectory('../src/classes'); require "config.php"; $changer = new ChangePassword(); $user = $_SESSION['user']; if (empty($_SESSION['user'])) { header("Location: ../index.php"); die("Redirecting to index.php"); } else { if (!empty($_POST) && $changer->checkFieldsCorrect($_POST)) { $query = "\n SELECT *\n FROM users\n WHERE\n email = :email\n "; $query_params = array(':email' => $user['email']); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch (PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $row = $stmt->fetch(); if ($row) { $check_password = PasswordUtils::hashPassword($_POST['current_password'], $row['salt']); if (PasswordUtils::checkMatchingPasswords($check_password, $row['password'])) { $changer->errorMessage = PasswordUtils::testPassword($_POST['new_password']); if (empty($changer->errorMessage)) { $changer->makePasswordChange($db, $_POST['new_password'], $row['salt'], $row['id']); $changer->success = "Password changed successfully."; } } else { $changer->errorMessage = "Incorrect password.";
public function handleRequest(Request $request, Response $response) { //$this->printParams($request); // Execute command switch ($request->getParameter("command")) { case "changePassword": $command = new ChangePassword(); $command->setPortal($this->portal); break; case "resetPassword": $command = new ResetPassword(); break; case "lockUnlockUser": $command = new LockUnlockUser(); break; case "trashRestoreUser": $command = new TrashRestoreUser(); break; case "createEmployee": $command = new CreateEmployee(); break; case "modifyEmployee": $command = new ModifyEmployee(); break; case "deleteEmployee": $command = new DeleteEmployee(); break; case "deleteEmployeeAJAX": $command = new DeleteEmployeeAJAX(); break; case "deleteMultipleEmployees": $command = new DeleteMultipleEmployees(); break; case "importCSVFile": $command = new ImportExcelFile(); break; case "deleteHistory": $command = new DeleteHistory(); break; case "exportEmployees": $command = new ExportEmployees(); break; case "createBranch": $command = new CreateBranch(); break; case "modifyBranch": $command = new ModifyBranch(); break; case "deleteBranch": $command = new DeleteBranch(); break; case "createCustomer": $command = new CreateCustomer(); break; case "modifyCustomer": $command = new ModifyCustomer(); break; case "deleteCustomer": $command = new DeleteCustomer(); break; case "assignEmployeeToCourse": $command = new AddParticipantToCourse(); break; case "assignEmployeesToCourseByCSV": $command = new AddParticipantsToCourseByCSV(); break; case "removeEmployeeFromCourse": $command = new RemoveParticipantFromCourse(); break; case "activateCourse": $command = new ActivateCourse(); break; case "deactivateCourse": $command = new DeactivateCourse(); break; case "changeCourseQuota": $command = new ChangeCourseQuota(); break; case "changeAdminPerspective": $command = new ChangeAdminPerspective(); break; case "getParticipants": $command = new GetParticipants(); break; case "showCourseDialog": $command = new ShowCourseDialog(); break; case "generateLicense": $command = new GenerateLicense(); break; case "getEncryptKey": $command = new GetEncryptKey(); break; case "setEncryptKey": $command = new SetEncryptKey(); break; case "installLicense": $command = new InstallLicense(); break; case "createCourse": $command = new CreateCourse(); break; case "toggleCustomerAdmin": $command = new ToggleCustomerAdmin(); break; case "toggleSystemAdmin": $command = new ToggleSystemAdmin(); break; case "changeCourseRole": $command = new ChangeCourseRole(); break; default: $command = new Dummy(); } try { $result = $command->execute($request, $response); if (is_array($result)) { return json_encode($result); } else { $this->portal->set_confirmation($result); } } catch (UsermanagementException $exception) { $this->portal->set_problem_description($exception->getProblem(), $exception->getHint()); } }
/** * Recovery password */ public function actionRecovery() { $model = new UserRecoveryForm(); $show_form = false; if (Yii::app()->user->id) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $email = isset($_GET['email']) ? $_GET['email'] : ''; $activkey = isset($_GET['activkey']) ? $_GET['activkey'] : ''; if ($email && $activkey) { $form2 = new ChangePassword(); $find = User::model()->notsafe()->findByAttributes(array('email' => $email)); if (isset($find) && $find->activkey == $activkey) { if (isset($_POST['ChangePassword'])) { $form2->attributes = $_POST['ChangePassword']; if ($form2->validate()) { $find->password = UserModule::encrypting($form2->password); $find->activkey = UserModule::encrypting(microtime() . $form2->password); if ($find->status == 0) { $find->status = 1; } $find->save(); $message = "Новый пароль сохранен"; $model = new UserLogin(); return $this->render('activation', array('model' => $model, 'message' => $message, 'show_login_form' => true)); } //echo'<pre>';print_r($form2);echo'</pre>';die; } else { $model = $form2; $show_form = true; $message = "Укажите новый пароль"; } } else { $message = "Неверная ссылка"; } } } $this->render('recovery', array('model' => $model, 'message' => $message, 'show_form' => $show_form)); }
public function actionChangePassword() { // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model = new ChangePassword(); if (isset($_POST['ChangePassword'])) { $model->attributes = $_POST['ChangePassword']; if ($model->save()) { $this->audit->logAudit(Yii::app()->user->id, new DateTime(), Constants::AUDITORIA_OBJETO_USUARIO, Constants::AUDITORIA_OPERACION_CAMBIAR_CONTRASENIA, Yii::app()->user->id); $this->render('/site/successfullOperation', array('header' => 'Contraseña modificada con éxito', 'message' => 'Haga click en volver para regresar a Mi Perfil', 'returnUrl' => Yii::app()->createUrl('user/miPerfil'))); return; } } $this->render('changePassword', array('model' => $model)); }