]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
If the user enters the same password as before, don't signal an error when the change...
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 15 Sep 2009 22:27:41 +0000 (22:27 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 15 Sep 2009 22:27:41 +0000 (22:27 +0000)
(closes issue #15492)
 Reported by: cbbs70a
 Patches:
       20090713__issue15492.diff.txt uploaded by tilghman (license 14)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@218730 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 796e8f52f7082dea1b5d1998aaf922680cd1f387..e6f3ab4ae7337e849de701b499972277fe520630 100644 (file)
@@ -680,18 +680,17 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
 
 static int change_password_realtime(struct ast_vm_user *vmu, const char *password)
 {
-       int res;
-       if (!ast_strlen_zero(vmu->uniqueid)) {
-               res = ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, NULL);
-               if (res > 0) {
+       int res = -1;
+       if (!strcmp(vmu->password, password)) {
+               /* No change (but an update would return 0 rows updated, so we opt out here) */
+               res = 0;
+       } else if (!ast_strlen_zero(vmu->uniqueid)) {
+               if (ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, NULL) > 0) {
                        ast_copy_string(vmu->password, password, sizeof(vmu->password));
                        res = 0;
-               } else if (!res) {
-                       res = -1;
                }
-               return res;
        }
-       return -1;
+       return res;
 }
 
 static void apply_options(struct ast_vm_user *vmu, const char *options)