Inheritance: extends Eloquen\Eloquent
Ejemplo n.º 1
0
 private function createAccountToUser(\Hybrid_Provider_Adapter $provider, Hybrid_User_Profile $profile, $session = null)
 {
     $account = new UserAccount();
     $account->fill(['network' => $provider->id, 'network_id' => $profile->identifier, 'url' => $profile->profileURL, 'session_data' => is_array($session) ? serialize($session) : $session]);
     $this->accounts()->save($account);
     return $account;
 }
Ejemplo n.º 2
0
 /**
  * 对用户的账户表中添加数据
  * @param int $uid 用户uid
  * @param string $channel 注册的渠道
  * @param int $os 注册的操作系统 1安卓,2iOS
  * @return int user_id
  */
 public static function add($uid, $channel, $os)
 {
     $info = new UserAccount();
     $info->uid = $uid;
     $info->create_time = time();
     $info->create_channel = $channel;
     $info->create_os = $os;
     $info->insert();
     return $info->id;
 }
Ejemplo n.º 3
0
 /**
  * 1.3版本的通过用户的 user_id获取用户的基本信息
  * @param  int $user_id 用户的 id
  */
 public static function getUserProfileVer13($user_id)
 {
     //获取用户的昵称性别头像
     $user_avatar = UserAvatar::get($user_id);
     //用户基本信息
     $user_profile = UserProfile::getProfile($user_id);
     //认证状态
     $sign_status = UserStatus::checkSignStatus($user_id) ? 1 : 0;
     //禁言状态
     $nosay_status = UserStatus::checkPressContentStatus($user_id) ? 1 : 0;
     //返回签到天数
     $sign_count = SignRecord::getSignCount($user_id);
     //获取 uid
     $uid = UserAccount::getUid($user_id);
     //被点赞的总数,获取的顺序,发布中的数量,对应的使用的标签的数量,->太麻烦,临时增加数据表,做点赞总数的记录,用user_status的字段吧 = =
     $like_count = UserStatus::getUserLikeCount($user_id);
     //验证身份的数组
     $auth_user_arr = Yii::$app->params['auth_account'];
     //组合数据
     $user_status = ['uid' => $uid, 'avatar' => $user_avatar, 'sign_count' => $sign_count, 'banned_status' => $nosay_status, 'sign_status' => $sign_status, 'like_count' => $like_count, 'access_status' => 1, 'account_status' => (int) in_array($uid, $auth_user_arr)];
     $user_info = array_merge($user_status, $user_profile);
     return $user_info;
 }
Ejemplo n.º 4
0
 public function unlinkUser($userAccountId, $userId)
 {
     $userAccount = UserAccount::whereId($userAccountId)->first();
     if ($userAccount->hasUserId($userId)) {
         $userAccount->removeUserId($userId);
         $userAccount->save();
     }
 }
 public function unlinkUser($userAccountId, $userId)
 {
     $userAccount = UserAccount::whereId($userAccountId)->first();
     if ($userAccount->hasUserId($userId)) {
         $userAccount->removeUserId($userId);
         $userAccount->save();
     }
     $user = User::whereId($userId)->first();
     if (!$user->public_id && $user->account->company->accounts->count() > 1) {
         $company = Company::create();
         $company->save();
         $user->account->company_id = $company->id;
         $user->account->save();
     }
 }
Ejemplo n.º 6
0
 /**
  * 修改密码,需要登录
  */
 public function actionEditPwd()
 {
     $response = Yii::$app->response;
     $response->format = \yii\web\Response::FORMAT_JSON;
     $request = Yii::$app->request;
     $this_path = $this->modules_name . "/" . lcfirst($this->class_name) . "/" . lcfirst(str_replace('action', "", __FUNCTION__));
     $this_allow_version = "1.1";
     //获取参数,和其他的分页的一样
     $param_os = (int) $request->post("os");
     //渠道
     $param_new_pwd = $request->post("new_pwd");
     //新密码
     $param_old_pwd = $request->post("old_pwd");
     //新密码
     //获取token
     $headers = $request->headers;
     $header_token = $headers->get('Token') ? $headers->get('Token') : $request->post("token");
     //加密之后的设备号,做到兼容post的方式
     //验证参数是不是有空的
     $check_null = Validators::validateAllNull([$param_os, $header_token]);
     if ($check_null === FALSE) {
         //错误信息,参数不全
         return $response->data = Error::errorJson($this_path, 1001);
     }
     //解密token
     if ($header_token == '233' && (YII_ENV_LOCAL == 'local' || YII_ENV_DEV)) {
         $uid = 1046;
     } else {
         $token_decode = RsaDecode::clientTokenToArray($header_token);
         if ($token_decode === FALSE) {
             //返回错误信息
             return $response->data = Error::errorJson($this_path, 9003);
         }
         //验证token
         $check_user_token = TokenUser::check($token_decode['uid'], $token_decode['deviceid'], $token_decode['logintime']);
         if ($check_user_token !== "0") {
             return $response->data = Error::errorJson($this_path, $check_user_token);
         }
         $uid = $token_decode['uid'];
     }
     $user_id = UserAccount::getUserId($uid);
     //测试数据 18312376990  123123
     $decode_old_pwd = RsaDecode::rsa_decode($param_old_pwd);
     $decode_new_pwd = RsaDecode::rsa_decode($param_new_pwd);
     //判断是不是有手机号注册
     $types = UserEmblem::findAllWay($user_id);
     if (!in_array(2, $types)) {
         //返回错误信息
         return $response->data = Error::errorJson($this_path, 4005);
     }
     //判断旧密码
     if (!UserPassword::check($user_id, $decode_old_pwd)) {
         return $response->data = Error::errorJson($this_path, 4006);
     }
     //修改密码
     $update = UserPassword::changePwd($user_id, $decode_new_pwd);
     if (!$update) {
         //修改密码错误
         return $response->data = Error::errorJson($this_path, 4007);
     }
     //返回对应的结果
     $return_json = ['request' => $this_path, 'info' => ['user_info' => App::getUserProfile($user_id)], 'version' => $this_allow_version, 'error_code' => 0, 'error' => ""];
     //接口访问记录
     CensusApi::add($user_id, $this_path);
     return $response->data = $return_json;
 }
Ejemplo n.º 7
0
 /**
  * 修改用户头像昵称性别,post 表单提交
  */
 public function actionEdit()
 {
     $response = Yii::$app->response;
     $response->format = \yii\web\Response::FORMAT_JSON;
     $request = Yii::$app->request;
     $this_path = $this->modules_name . "/" . lcfirst($this->class_name) . "/" . lcfirst(str_replace('action', "", __FUNCTION__));
     $this_allow_version = "1.1";
     //获取参数
     $param_os = (int) $request->post("os");
     //系统
     $param_gender = (int) $request->post("gender");
     //性别 1男 2女
     $param_nikename = $request->post("nikename");
     //新的用户昵称
     $param_avatar = isset($_FILES['avatar']['error']);
     //头像上传,如果值是 true 再看 error 是不是0,如果是0就表示有对应的头像上传
     if ($param_avatar == true && $_FILES['avatar']['error'] == 0) {
         $param_avatar = TRUE;
         //头像存在
     } else {
         $param_avatar = null;
         //头像不存在
     }
     //获取token
     $headers = $request->headers;
     $header_token = $headers->get('Token') ? $headers->get('Token') : $request->post("token");
     //加密之后的设备号,做到兼容post的方式
     //验证参数是不是有空的
     $check_null = Validators::validateAllNull([$param_os, $header_token]);
     if ($check_null === FALSE) {
         //错误信息,参数不全
         return $response->data = Error::errorJson($this_path, 1001);
     }
     //验证三个参数是不是至少有一个
     $check_all_null = Validators::validateNotAllNull([$param_gender, $param_nikename, $param_avatar]);
     if ($check_all_null === FALSE) {
         //错误信息,参数不全
         return $response->data = Error::errorJson($this_path, 1002);
     }
     //测试环境本地环境对 token 不做验证
     if ($header_token == '233' && (YII_ENV_LOCAL == 'local' || YII_ENV_DEV)) {
         $uid = 1047;
     } else {
         $token_decode = RsaDecode::clientTokenToArray($header_token);
         if ($token_decode === FALSE) {
             //返回错误信息
             return $response->data = Error::errorJson($this_path, 9003);
         }
         //解密
         //验证token
         $check_user_token = TokenUser::check($token_decode['uid'], $token_decode['deviceid'], $token_decode['logintime']);
         if ($check_user_token !== "0") {
             return $response->data = Error::errorJson($this_path, $check_user_token);
         }
         $uid = $token_decode['uid'];
     }
     $user_id = UserAccount::getUserId($uid);
     //性别
     if ($param_gender) {
         $update_gender = UserProfile::editGender($user_id, $param_gender);
         //验证性别
         if (!in_array($param_gender, [1, 2])) {
             //性别输入不符
             return $response->data = Error::errorJson($this_path, 4008);
         }
         if (!$update_gender) {
             return $response->data = Error::errorJson($this_path, 5001);
         }
     }
     //昵称
     if ($param_nikename) {
         $update_nikename = UserProfile::editNikename($user_id, $param_nikename);
         if (!$update_nikename) {
             return $response->data = Error::errorJson($this_path, 5001);
         }
     }
     //头像
     if ($param_avatar) {
         $avatar_url = WebImgToLocal::simpleUploadV2($_FILES['avatar']);
         UserAvatar::changeAvatar($user_id, $avatar_url);
     }
     //返回对应的结果
     $return_json = ['request' => $this_path, 'info' => ['user_info' => App::getUserProfile($user_id)], 'version' => $this_allow_version, 'error_code' => 0, 'error' => ""];
     //接口访问记录
     CensusApi::add($user_id, $this_path);
     return $response->data = $return_json;
 }
Ejemplo n.º 8
0
 public function user()
 {
     $user = UserAccount::find(1)->user;
     dd($user);
 }
Ejemplo n.º 9
0
 public function tearDown()
 {
     User::orderBy('id', 'desc')->delete();
     UserAccount::orderBy('id', 'desc')->delete();
 }