修改登录时的逻辑问题

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

View File

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