Subversion Repositories oidplus

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. if ($_POST["action"] == "change_ra_password") {
  21.         $handled = true;
  22.  
  23.         $error = false;
  24.         $email = $_POST['email'];
  25.  
  26.         if (!OIDplus::authUtils()::isRaLoggedIn($email) && !OIDplus::authUtils()::isAdminLoggedIn()) {
  27.                 die('Authentification error. Please log in as the RA to update its data.');
  28.         }
  29.  
  30.         $old_password = $_POST['old_password'];
  31.         $password1 = $_POST['new_password1'];
  32.         $password2 = $_POST['new_password2'];
  33.  
  34.         if ($password1 !== $password2) {
  35.                 die('Passwords are not equal');
  36.         }
  37.  
  38.         if (strlen($password1) < OIDplus::config()->minRaPasswordLength()) {
  39.                 die('New password is too short. Minimum password length: '.OIDplus::config()->minRaPasswordLength());
  40.         }
  41.  
  42.         $ra = new OIDplusRA($email);
  43.         if (!$ra->checkPassword($old_password)) {
  44.                 die('Old password incorrect');
  45.         }
  46.         $ra->change_password($password1);
  47.  
  48.         if (!$error) echo "OK";
  49. }
  50.