Пример #1
0
 /**
  * @description 重置密码
  * @author
  * @final
  * @param int $uid 学生id
  * @param string $new_password 新密码
  * @param string $confirm_password 重复密码
  */
 public function reset_password()
 {
     if (!$this->check_power('student_manage')) {
         return;
     }
     $new_password = $this->input->post('new_password');
     $new_confirm_password = $this->input->post('confirm_password');
     $uid = intval($this->input->post('uid'));
     if (is_string($passwd_msg = is_password($new_password))) {
         output_json(CODE_ERROR, $passwd_msg);
     }
     if (!strlen(trim($new_confirm_password))) {
         output_json(CODE_ERROR, '确认密码不能为空.');
     }
     if ($new_confirm_password != $new_password) {
         output_json(CODE_ERROR, '两次密码输入不一致.');
     }
     //检查是否存在该学生
     $passwd = StudentModel::get_student($uid, 'password');
     if (!count($passwd)) {
         output_json(CODE_ERROR, '不存在该学生.');
     }
     //修改学生密码
     $flag = StudentModel::reset_password($uid, my_md5($new_password));
     if (!$flag) {
         output_json(CODE_ERROR, '密码修改失败,请重试');
     }
     output_json(CODE_SUCCESS, '密码修改成功.');
 }