Commit cf4e58ba authored by 吴贤德's avatar 吴贤德

修改用户时如果没有GA秘钥则生成保存

parent 4eff2193
...@@ -56,6 +56,7 @@ class UserAction extends CommonAction{ ...@@ -56,6 +56,7 @@ class UserAction extends CommonAction{
$this->display(); $this->display();
} }
public function addUserHandle(){ public function addUserHandle(){
$ga = new PHPGangsta_GoogleAuthenticator();
$UserModel = D("User"); $UserModel = D("User");
$RoleUserModel = D("RoleUser"); $RoleUserModel = D("RoleUser");
$SpUserMapModel = D("SpUserMap"); $SpUserMapModel = D("SpUserMap");
...@@ -86,6 +87,13 @@ class UserAction extends CommonAction{ ...@@ -86,6 +87,13 @@ class UserAction extends CommonAction{
} }
unset($user['account']); unset($user['account']);
unset($user['password']); unset($user['password']);
$user["secret"]=$_POST["secret"];
if ($user["secret"]==""){
$secret = $ga->createSecret();
$user["secret"]=$secret;
}
if($UserModel->save($user)){ if($UserModel->save($user)){
if($RoleUserModel->where("user_id=".$uid)->delete()){ if($RoleUserModel->where("user_id=".$uid)->delete()){
$role["role_id"]=I("role_id","",int); $role["role_id"]=I("role_id","",int);
...@@ -107,7 +115,7 @@ class UserAction extends CommonAction{ ...@@ -107,7 +115,7 @@ class UserAction extends CommonAction{
$user["update_time"]=time(); $user["update_time"]=time();
$user["remark"]=''; $user["remark"]='';
$ga = new PHPGangsta_GoogleAuthenticator();
$secret = $ga->createSecret(); $secret = $ga->createSecret();
$user["secret"]=$secret; $user["secret"]=$secret;
......
...@@ -71,6 +71,7 @@ $().ready(function(){ ...@@ -71,6 +71,7 @@ $().ready(function(){
</div> </div>
<div><label class="label_s">GA秘钥:</label> <div><label class="label_s">GA秘钥:</label>
{$user.secret} {$user.secret}
<input type="hidden" name="secret" value="{$user.secret}">
</div> </div>
</if> </if>
<div><label class="label_s">昵称:</label> <div><label class="label_s">昵称:</label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment