Browse Source

Make change password feature work

tags/v1.0
Skylar Ittner 2 years ago
parent
commit
400dffa96e
2 changed files with 8 additions and 4 deletions
  1. 3
    0
      index.php
  2. 5
    4
      lib/login.php

+ 3
- 0
index.php View File

@@ -34,6 +34,7 @@ if ($VARS['progress'] == "1") {
34 34
                     $alert = lang("password expired", false);
35 35
                     $alerttype = "info";
36 36
                     $_SESSION['username'] = strtolower($VARS['username']);
37
+                    $_SESSION['uid'] = $database->get('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
37 38
                     $change_password = true;
38 39
                     break;
39 40
                 case "NORMAL":
@@ -109,6 +110,8 @@ if ($VARS['progress'] == "1") {
109 110
             $alerttype = MESSAGES["password_updated"]["type"];
110 111
         }
111 112
         switch (count($error)) {
113
+            case 0:
114
+                break;
112 115
             case 1:
113 116
                 $alert = lang(MESSAGES[$error[0]]["string"], false);
114 117
                 $alerttype = MESSAGES[$error[0]]["type"];

+ 5
- 4
lib/login.php View File

@@ -87,19 +87,20 @@ function change_password($old, $new, $new2, &$error) {
87 87
         // Figure out how to change the password, then do it
88 88
         $acctloc = account_location($_SESSION['username']);
89 89
         if ($acctloc == "LOCAL") {
90
-            $database->update('accounts', ['password' => encryptPassword($VARS['newpass'])], ['uid' => $_SESSION['uid']]);
91
-            $_SESSION['password'] = $VARS['newpass'];
90
+            $database->update('accounts', ['password' => encryptPassword($new), 'acctstatus' => 1], ['uid' => $_SESSION['uid']]);
91
+            $_SESSION['password'] = $new;
92 92
             insertAuthLog(3, $_SESSION['uid']);
93 93
             return true;
94 94
         } else if ($acctloc == "LDAP") {
95 95
             try {
96 96
                 $repository = $ldap->getRepository(LdapObjectType::USER);
97 97
                 $user = $repository->findOneByUsername($_SESSION['username']);
98
-                $user->setPassword($VARS['newpass']);
98
+                $user->setPassword($new);
99 99
                 $user->setpasswordMustChange(false);
100 100
                 $ldap->persist($user);
101
+                $database->update('accounts', ['acctstatus' => 1], ['uid' => $_SESSION['uid']]);
101 102
                 insertAuthLog(3, $_SESSION['uid']);
102
-                $_SESSION['password'] = $VARS['newpass'];
103
+                $_SESSION['password'] = $new;
103 104
                 return true;
104 105
             } catch (\Exception $e) {
105 106
                 // Stupid password complexity BS error

Loading…
Cancel
Save