Exemplo n.º 1
0
 public function user_by_id($value, $args, $context, ResolveInfo $info)
 {
     /*$user = array(
           'auth' => array(),
           'profile' => array(),
       );
       $user_auth = UserAuthModel::getAuthByUsername($args['username_like']);
       if ($user_auth) {
           $user['auth'] = $user_auth->toArray();
           $user_profile = UserProfileModel::getProfile($user_auth->id);
           $user['profile'] = $user_profile->toArray();
       }*/
     $user = array();
     $user_auth = UserAuthModel::getAuth($args['id']);
     if ($user_auth) {
         $user = $user_auth->toArray();
         $user_profile = UserProfileModel::getProfile($user_auth->id);
         if ($user_profile) {
             $user += $user_profile->toArray();
         }
         if (!isset($user['avatar']) || empty($user['avatar'])) {
             // todo
             $user['avatar'] = 'http://cdn.tachigo.com/user/img/avatar.gif';
         }
     }
     return $user;
 }
Exemplo n.º 2
0
 public function __invoke()
 {
     /** @var \Tachigo\User\Aware\Hook\UserHook $hook */
     $hook = $this->getHook();
     $user_id = $hook->getUserId();
     $hook_results = $hook->getResults();
     $hook_results['auth'] = UserAuthModel::getAuth($user_id);
     $hook_results['profile'] = UserProfileModel::getProfile($user_id);
     $hook->setResults($hook_results);
     /*$hook = $this->getHook();
       $user_id = $hook->getUserId();
       $hook_results = $hook->getResults();
       $db = UserDatabase::getDb();
       $hook_results['auth'] = $db->getUserInfo($user_id);
       $hook_results['profile'] = $hook_results['auth'];
       $hook->setResults($hook_results);*/
 }
Exemplo n.º 3
0
 private function handlePassword($auth_id)
 {
     $user_auth = UserAuthModel::getAuth($auth_id);
     if (!$user_auth) {
         throw new \Exception('用户不存在');
     }
     $request = $this->getRequest();
     $posts = $request->request;
     $password = $posts->get('password');
     $confirm_password = $posts->get('confirm_password');
     // 密码
     if (!$password) {
         throw new \Exception('密码不能为空');
     }
     if (strlen($password) < 6) {
         throw new \Exception('密码至少6位字符');
     }
     if (!$confirm_password) {
         throw new \Exception('确认密码不能为空');
     }
     if ($password != $confirm_password) {
         throw new \Exception('密码与确认密码不一致');
     }
     $user_auth->password = md5($password);
     // 保存
     UserAuthModel::saveAuth($user_auth);
 }
Exemplo n.º 4
0
 /**
  * @param $id
  * @return null|UserAuthModel
  */
 public function getUserAuthInfo($id)
 {
     $user_auth = UserAuthModel::getAuth($id);
     return $user_auth;
 }