private function __preAccountSeller($data) { $pamShopData['login_account'] = trim($data['login_account']); $pamShopData['createtime'] = $data['createtime'] ? $data['createtime'] : time(); $pamShopData['modified_time'] = $data['modified_time'] ? $data['modified_time'] : time(); $loginPassword = pam_encrypt::make(trim($data['login_password'])); $pamShopData['login_password'] = $loginPassword; return $pamShopData; }
function editUser(&$data) { if ($data['userpass']) { $data[':account@desktop']['login_password'] = pam_encrypt::make(trim($data['userpass'])); } $data['pam_account']['account_type'] = pamAccount::getAuthType($this->app->app_id); $data['pam_account']['createtime'] = time(); //return parent::save($data); parent::save($data); exit; }
function post_install($options) { logger::info('Create admin account'); //设置用户体系,前后台互不相干 pamAccount::registerAuthType('desktop', 'shopadmin', '后台管理系统'); //todo: 封装成更简单的函数 $use_pass_data['login_name'] = $options['admin_uname']; $use_pass_data['createtime'] = time(); $password = pam_encrypt::make($options['admin_password']); $account = array('pam_account' => array('login_name' => $options['admin_uname'], 'login_password' => $password, 'account_type' => 'shopadmin', 'createtime' => $use_pass_data['createtime']), 'name' => $options['admin_uname'], 'super' => 1, 'status' => 1); app::get('desktop')->model('users')->save($account); }
/** * @brief 后台企业重置密码 * * @param int $sellerId 重置密码的seller_id * @param string $password 重置的新密码 * * @return bool */ public function resetPwd($sellerId, $data) { $data = utils::_filter_input($data); $accountShopModel = app::get('sysshop')->model('account'); $filter = array('seller_id' => $sellerId); $account = $accountShopModel->getRow('seller_id,login_password', $filter); if (!$account) { throw new \LogicException(app::get('sysshop')->_('修改失败')); } //检查密码合法,是否一致 $this->checkPassport($data['login_password'], $data['psw_confirm']); $pamShopData['login_password'] = pam_encrypt::make(trim($data['login_password'])); $pamShopData['seller_id'] = $sellerId; $pamShopData['modified_time'] = time(); if (!($sellerId = $accountShopModel->save($pamShopData))) { throw new \LogicException(app::get('sysshop')->_('修改失败')); } return true; }
/** * 修改密码,需要使用旧密码进行修改,新密码和确认密码需要一致 * * @param int $userId 修改密码的user_id * @param array $data * * @return bool */ public function modifyPwd($data) { $data = utils::_filter_input($data); $pamUserModel = app::get('sysuser')->model('account'); $account = $pamUserModel->getRow('modified_time,createtime,login_password,login_account', array('user_id' => $data['user_id'])); if (!$account) { throw new \LogicException(app::get('sysuser')->_('会员信息有误')); } if ($data['type'] == "update" && $data['old_pwd']) { if (!pam_encrypt::check($data['old_pwd'], $account['login_password'])) { throw new \LogicException(app::get('sysuser')->_('原密码错误')); } } //检查密码合法,是否一致 $this->checkPwd($data['new_pwd'], $data['confirm_pwd']); $pamUserData['login_password'] = pam_encrypt::make($data['new_pwd']); if ($data['uname']) { $type = kernel::single('pam_tools')->checkLoginNameType($data['uname']); $this->checkSignupAccount(trim($data['uname']), $type); $pamUserData['login_account'] = $data['uname']; $pamUserData['login_type'] = 'common'; } $pamUserData['user_id'] = $data['user_id']; $pamUserData['modified_time'] = time(); if (!($userId = $pamUserModel->save($pamUserData))) { throw new \LogicException(app::get('sysuser')->_('修改失败')); } return true; }
function chkpassword() { $this->begin('?app=desktop&ctl=users&act=index'); $users = $this->app->model('users'); if ($_POST) { $sdf = $users->dump($_POST['user_id'], '*', array(':account@desktop' => array('*'), 'roles' => array('*'))); $old_password = $sdf['account']['login_password']; //这里加了一个判断,判断是自行改密码还是超级管理员去修改 //如果是自行改密码,就去匹配自己的密码。如果是管理员的话,就去匹配超级管理员的密码 if ($_POST['self'] == 'self') { $_POST['user_id'] = $this->user->get_id(); $filter['account_id'] = $this->user->get_id(); $filter['account_type'] = pamAccount::getAuthType(); } else { $super_row = $users->getList('user_id', array('super' => '1')); $filter['account_id'] = $super_row[0]['user_id']; $filter['account_type'] = pamAccount::getAuthType(); $super_data = $users->dump($filter['account_id'], '*', array(':account@desktop' => array('*'))); } $pass_row = app::get('desktop')->model('account')->getRow('account_id,login_password', $filter); if (!$pass_row || !pam_encrypt::check(input::get('old_login_password'), $pass_row['login_password'])) { $this->end(false, app::get('desktop')->_('管理员密码或原始密码不正确')); } elseif (!(strlen($_POST['new_login_password']) >= 6 && preg_match("/\\d+/", $_POST['new_login_password']) && preg_match("/[a-zA-Z]+/", $_POST['new_login_password']))) { $this->end(false, app::get('desktop')->_('密码必须同时包含字母及数字且长度不能小于6!')); } elseif ($sdf['account']['login_name'] == $_POST['new_login_password']) { $this->end(false, app::get('desktop')->_('用户名与密码不能相同')); } elseif ($_POST['new_login_password'] !== $_POST['pam_account']['login_password']) { // //修改0000!=00000为true的问题@lujy $this->end(false, app::get('desktop')->_('两次密码不一致')); } else { $_POST['pam_account']['account_id'] = $_POST['user_id']; $_POST['pam_account']['login_password'] = pam_encrypt::make(trim($_POST['new_login_password'])); $users->save($_POST); $this->end(true, app::get('desktop')->_('密码修改成功')); } } $pagedata['user_id'] = $_GET['id']; $pagedata['self'] = $_GET['self']; $this->adminlog("修改平台管理员密码[{$_POST['user_id']}]", 1); return $this->page('desktop/users/chkpass.html', $pagedata); }