forked from Business/AccountHub
Make change password feature work
This commit is contained in:
parent
991f36b57f
commit
400dffa96e
@ -34,6 +34,7 @@ if ($VARS['progress'] == "1") {
|
|||||||
$alert = lang("password expired", false);
|
$alert = lang("password expired", false);
|
||||||
$alerttype = "info";
|
$alerttype = "info";
|
||||||
$_SESSION['username'] = strtolower($VARS['username']);
|
$_SESSION['username'] = strtolower($VARS['username']);
|
||||||
|
$_SESSION['uid'] = $database->get('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
|
||||||
$change_password = true;
|
$change_password = true;
|
||||||
break;
|
break;
|
||||||
case "NORMAL":
|
case "NORMAL":
|
||||||
@ -109,6 +110,8 @@ if ($VARS['progress'] == "1") {
|
|||||||
$alerttype = MESSAGES["password_updated"]["type"];
|
$alerttype = MESSAGES["password_updated"]["type"];
|
||||||
}
|
}
|
||||||
switch (count($error)) {
|
switch (count($error)) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$alert = lang(MESSAGES[$error[0]]["string"], false);
|
$alert = lang(MESSAGES[$error[0]]["string"], false);
|
||||||
$alerttype = MESSAGES[$error[0]]["type"];
|
$alerttype = MESSAGES[$error[0]]["type"];
|
||||||
|
@ -87,19 +87,20 @@ function change_password($old, $new, $new2, &$error) {
|
|||||||
// Figure out how to change the password, then do it
|
// Figure out how to change the password, then do it
|
||||||
$acctloc = account_location($_SESSION['username']);
|
$acctloc = account_location($_SESSION['username']);
|
||||||
if ($acctloc == "LOCAL") {
|
if ($acctloc == "LOCAL") {
|
||||||
$database->update('accounts', ['password' => encryptPassword($VARS['newpass'])], ['uid' => $_SESSION['uid']]);
|
$database->update('accounts', ['password' => encryptPassword($new), 'acctstatus' => 1], ['uid' => $_SESSION['uid']]);
|
||||||
$_SESSION['password'] = $VARS['newpass'];
|
$_SESSION['password'] = $new;
|
||||||
insertAuthLog(3, $_SESSION['uid']);
|
insertAuthLog(3, $_SESSION['uid']);
|
||||||
return true;
|
return true;
|
||||||
} else if ($acctloc == "LDAP") {
|
} else if ($acctloc == "LDAP") {
|
||||||
try {
|
try {
|
||||||
$repository = $ldap->getRepository(LdapObjectType::USER);
|
$repository = $ldap->getRepository(LdapObjectType::USER);
|
||||||
$user = $repository->findOneByUsername($_SESSION['username']);
|
$user = $repository->findOneByUsername($_SESSION['username']);
|
||||||
$user->setPassword($VARS['newpass']);
|
$user->setPassword($new);
|
||||||
$user->setpasswordMustChange(false);
|
$user->setpasswordMustChange(false);
|
||||||
$ldap->persist($user);
|
$ldap->persist($user);
|
||||||
|
$database->update('accounts', ['acctstatus' => 1], ['uid' => $_SESSION['uid']]);
|
||||||
insertAuthLog(3, $_SESSION['uid']);
|
insertAuthLog(3, $_SESSION['uid']);
|
||||||
$_SESSION['password'] = $VARS['newpass'];
|
$_SESSION['password'] = $new;
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Stupid password complexity BS error
|
// Stupid password complexity BS error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user