check old_password if passed to self-service API, require with config setting, RT...
authorIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 09:05:39 +0000 (02:05 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 09:05:39 +0000 (02:05 -0700)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/Conf.pm

index 5b590da..47f3bd8 100644 (file)
@@ -2856,6 +2856,13 @@ sub myaccount_passwd {
   my $error = '';
 
   my $conf = new FS::Conf;
+
+  return { 'error' => 'Incorrect current password.' }
+    if  ( exists($p->{'old_password'})
+          || $conf->exists('selfservice-password_change_oldpass')
+        )
+    && ! $svc_acct->check_password($p->{'old_password'});
+
   $error = 'Password too short.'
     if length($p->{'new_password'}) < ($conf->config('passwordmin') || 6);
   $error = 'Password too long.'
index 751a959..adf5c86 100644 (file)
@@ -2869,6 +2869,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'selfservice-password_change_oldpass',
+    'section'     => 'self-service',
+    'description' => 'Require old password to be entered again for password changes (in addition to being logged in), at the API level.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'selfservice-hide_invoices-taxclass',
     'section'     => 'self-service',
     'description' => 'Hide invoices with only this package tax class from self-service and supress sending (emailing, printing, faxing) them.  Typically set to something like "Previous balance" and used when importing legacy invoices into legacy_cust_bill.',