HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
UserIdentity.php
Go to the documentation of this file.
1 <?php
2 
8 class UserIdentity extends CUserIdentity
9 {
10  private $_id;
13  const ERROR_STATUS_BAN = 5;
23  public function authenticate()
24  {
25  if (strpos($this->username, "@")) {
26  $user = User::model()->notsafe()->findByAttributes(array('email' => $this->username));
27  } else {
28  $user = User::model()->notsafe()->findByAttributes(array('username' => $this->username));
29  }
30  if ($user === null) {
31  if (strpos($this->username, "@")) {
32  $this->errorCode = self::ERROR_EMAIL_INVALID;
33  } else {
34  $this->errorCode = self::ERROR_USERNAME_INVALID;
35  }
36  } elseif (Yii::app()->getModule('user')->encrypting($this->password) !== $user->password) {
37  $this->errorCode = self::ERROR_PASSWORD_INVALID;
38  } elseif ($user->status == 0 && Yii::app()->getModule('user')->loginNotActiv == false) {
39  $this->errorCode = self::ERROR_STATUS_NOTACTIV;
40  } elseif ($user->status == -1) {
41  $this->errorCode = self::ERROR_STATUS_BAN;
42  } else {
43  $this->_id = $user->id;
44  $this->username = $user->username;
45  $this->errorCode = self::ERROR_NONE;
46  }
47 
48  return !$this->errorCode;
49  }
50 
54  public function getId()
55  {
56  return $this->_id;
57  }
58 }