public function edit() { $must = array(); $this->check_param($must); $this->check_sign(); extract($this->params); do { $res = $this->Base_model->ci_update(T_EMPLOYEE, array('id' => $id), array('account' => $employee_name, 'pwd' => pass_encrypt($employee_pwd))); $this->st($res); } while (0); $this->op(); }
public function login() { $must = array('store_account', 'pwd'); $this->check_param($must); $this->check_sign(); extract($this->params); do { $this->Table_model->init(T_STORE_ACCOUNT); $res = $this->Table_model->record_one(array('name' => $store_account)); if ($res) { if ($res['pwd'] == pass_encrypt($pwd)) { $session = $this->_set_store_login_seesion($res['id']); $this->st(array('store_session' => $session), "登录成功!"); break; } else { $this->st(array(), "登录失败,密码错误", API_PWD_ERR); break; } } $this->st(array(), "登录失败,账号错误", API_NORMAL_ERR); } while (0); $this->op(); }
public function find_pwd() { $must = array("phone", 'new_pwd', 're_new_pwd', 'verify_code'); $this->check_param($must); $this->check_sign(); extract($this->params); do { //手机是否已经注册 ? $is_register = $this->User_model->is_phone_register($phone); if ($is_register == false) { $this->st(array('phone' => $phone), "未注册的手机号,无法找回密码!", API_PHONE_REGISTERED); break; } //验证码是否错误 ? $is_verify_code = $this->User_model->is_verify_code($phone, $verify_code); if ($is_verify_code == FALSE) { $this->st(array('verify' => $verify_code), "用户注册验证码错误", API_REGISTER_VERIFY_CODE_ERR); break; } //密码格式是否错误 ? // if( !preg_match('/^[a-zA-Z0-9_]{6,20}$/',$new_pwd) ){ // $this->st(array(),'密码格式错误(请输入6到20位字母数字组合)',API_PWD_FORMAT_ERR); // break; // } //密码是否输入错误 ? if ($new_pwd != $re_new_pwd) { $this->st(array('pwd' => $new_pwd, 're_new_pwd' => $re_new_pwd), "两次输入的密码不一致!", API_PWD_ERR); break; } $uid = $this->User_model->get_uid(array('phone' => $phone)); //如果新密码与旧的密码相同 $pwd = $this->User_model->info($uid)['pwd']; if ($pwd == pass_encrypt($new_pwd)) { $this->st(array('new_pwd' => $new_pwd), "找回密码成功!请谨慎保管!"); break; } //更新为新密码 if ($uid) { $is_update = $this->User_model->update($uid, array('pwd' => pass_encrypt($new_pwd))); if ($is_update) { $this->st(array('new_pwd' => $new_pwd), "找回密码成功!请谨慎保管!"); break; } } $this->st(array(), "找回密码失败!请重试!", API_PWD_MODIFY_ERR); } while (0); $this->op(); }