Browse Source

Fix non matching password error when not changing password

Zebulon McCorkle 8 months ago
parent
commit
647f9b7aec
No account linked to committer's email address
1 changed files with 5 additions and 5 deletions
  1. 5
    5
      src/routes/update.ts

+ 5
- 5
src/routes/update.ts View File

@@ -67,20 +67,20 @@ export default async function update(ctx: Context) {
67 67
             loginShell: [ctx.request.body.loginShell],
68 68
             sshPublicKey: [ctx.request.body.sshPublicKey],
69 69
         };
70
-    
71
-        if (ctx.request.body.userPassword === ctx.request.body.userPasswordRepeat && ctx.request.body.userPassword != null && ctx.request.body.userPassword != '') {
70
+
71
+        if (ctx.request.body.userPassword === ctx.request.body.userPasswordRepeat && ctx.request.body.userPassword != null && ctx.request.body.userPassword !== '') {
72 72
             modification.userPassword = ['{CRYPT}' + await crypt(ctx.request.body.userPassword, crypt.createSalt('sha512'))];
73
-        } else if (ctx.request.body.userPassword != null || ctx.request.body.userPasswordRepeat != null) {
73
+        } else if (ctx.request.body.userPassword !== '' && ctx.request.body.userPasswordRepeat !== '' && (ctx.request.body.userPassword != null || ctx.request.body.userPasswordRepeat != null)) {
74 74
             ctx.redirect('/info?uid=' + encodeURIComponent(uid) + '&error=' + encodeURIComponent('Passwords do not match.'));
75 75
             return;
76 76
         }
77
-    
77
+
78 78
         const changes = transformModification(modification);
79 79
         for (const change of changes) {
80 80
             debug('changing', change);
81 81
             await client.modify(dn, change);
82 82
         }
83
-    
83
+
84 84
         ctx.redirect('/info?uid=' + encodeURIComponent(uid) + '&success=true');
85 85
     } catch (e) {
86 86
         ctx.redirect('/info?uid=' + encodeURIComponent(ctx.params.uid) + '&error=' + encodeURIComponent('Unknown error: ' + e.toString()));