Example #1
0
 public static function socialLogin($uid, $name, $email, $password, $hash)
 {
     $model = UsersModel::model()->where("`social_uid`='{$uid}'  OR `email`='" . $email . "'")->findRow();
     if (!$model) {
         $random_password = rand(10000, 99999);
         $model = new UsersModel();
         $name = trim($name);
         $email = trim($email);
         $password = trim($password);
         $model->name = $name;
         $model->login = $email;
         $model->password = md5($password);
         $model->email = $email;
         $model->is_admin = 0;
         $model->status = 1;
         $model->card_main_id = 1;
         $model->card_main_new_id = 2;
         $model->social_uid = $uid;
         $model->hash = $hash;
         $model->type = 2;
         $model->save();
         DefaultController::sendEmailToUser($model->email, $password, $model->hash, $model->password);
     } else {
         if ($model->status != 0) {
             self::setFields($model);
         } else {
             header("Location: /deactivate");
             exit;
         }
         header("Location: /");
     }
     self::setFields($model);
     header("Location: /");
 }