예제 #1
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $admin = TAdmin::model()->findByAttributes(array('username' => $this->username));
     $anggota = TAnggota::model()->findByAttributes(array('username' => $this->username));
     $perusahaan = TPerusahaan::model()->findByAttributes(array('username' => $this->username));
     if ($admin !== null) {
         if ($admin->password != $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     } else {
         if ($anggota !== null) {
             if ($anggota->password != $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->errorCode = self::ERROR_NONE;
             }
         } else {
             if ($perusahaan !== null) {
                 if ($perusahaan->password != $this->password) {
                     $this->errorCode = self::ERROR_PASSWORD_INVALID;
                 } else {
                     $this->errorCode = self::ERROR_NONE;
                 }
             }
         }
     }
     return !$this->errorCode;
 }
예제 #2
0
 public static function isAdmin()
 {
     $model = TAdmin::model()->findByAttributes(array('username' => Yii::app()->user->id, 'role' => 'admin'));
     if ($model !== null) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 public function actionGantipassword()
 {
     $this->layout = '//layouts/akun/main';
     if (isset($_POST['password_baru'])) {
         $member = TAdmin::model()->findByAttributes(array('username' => Yii::app()->user->id));
         $member->password = $_POST['password_baru'];
         $member->save();
     }
     $this->render('gantipassword');
 }