修改登录时的逻辑问题

This commit is contained in:
Li Jianxuan 2014-04-22 09:52:59 +00:00
parent 2df66ef940
commit 70f4202ae6
2 changed files with 20 additions and 16 deletions

View File

@ -136,9 +136,9 @@ class Account implements EventManagerAwareInterface
if(isset($cache_data['error']) && !empty($cache_data['error']))
{
return array('error'=>$cache_data);
return array('error'=>$cache_data['error']);
}
$state = $this->storeLogin($cache_data);
if(isset($state['success']))
@ -156,17 +156,14 @@ class Account implements EventManagerAwareInterface
$auth = new AuthenticationService();
$auth->setStorage(new SessionStorage($this->config->session_namespace));
unset($data[$this->conf->field->pwd]);
$user = (object)$data;
$email = $data['email'];
$email = $user->email;
$results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email'));
$data['avatar'] = $results->last();
$user = json_decode(json_encode($data));;
$user->avatar = $results->last();
$auth->getStorage()->write($user);
$id = $data['id'];
$id = $user->id;
$results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id'));
return array('success'=>1);

View File

@ -23,9 +23,10 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent
$this->db = new Db();
$this->conf = Config::get();
$config = Config::get('sync');
$this->dsn = array(
array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''),
array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''),
array('host'=>$config->qinghaihu->hostname,'db'=>$config->qinghaihu->database,'user'=>$config->qinghaihu->username,'pwd'=>$config->qinghaihu->password),
//array('host'=>'localhost','db'=>'','user'=>'','pwd'=>''),
);
}
@ -76,7 +77,7 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent
$uname_avalible = false;
if( isset($row['error']) && !empty($row['error']) )
if( isset($row['error']) || !empty($row['error']) )
{
if(count($this->dsn) > 0)
{
@ -93,14 +94,20 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent
}
}
}
}else{
$uname_avalible = true;
}
if(!$uname_avalible)
if($uname_avalible == false)
{
return $row;
else
}else if($uname_avalible == true){
$this->last_login_data = $row;
return $this->checkPwd($row,$password);
}else{
return array("error"=>'用户名密码错误');
}
return $this->checkPwd($row,$password);
}
//获取数据
@ -111,7 +118,7 @@ class LoginHandle implements \Sookon\User\Event\LoginEvent
if(empty($memberTable))
$memberTable = $this->conf->table->member;
$sql = "SELECT id,{$this->conf->field->pwd} FROM $memberTable WHERE {$this->conf->field->uname}=?";
$sql = "SELECT * FROM $memberTable WHERE {$this->conf->field->uname}=?";
$sth = $db->prepare($sql);
$rs = $sth->execute(array($username));
$row = $sth->fetch();