当前位置: 首页>>代码示例>>PHP>>正文


PHP ParseUser::getCurrentUser方法代码示例

本文整理汇总了PHP中Parse\ParseUser::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseUser::getCurrentUser方法的具体用法?PHP ParseUser::getCurrentUser怎么用?PHP ParseUser::getCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse\ParseUser的用法示例。


在下文中一共展示了ParseUser::getCurrentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: alerts

 public function alerts($cc = null)
 {
     $current_user = ParseUser::getCurrentUser();
     $query = new ParseQuery("Notifications");
     $query->equalTo("for", $current_user);
     $query->equalTo("read", false);
     $query->includeKey('by');
     $query->includeKey('message');
     try {
         $notifications = $query->find();
         $notes = array();
         foreach ($notifications as $notify) {
             if (!empty($notify->get('message'))) {
                 if ($notify->get('message')->get('chatRoom')->getObjectId() == $cc) {
                     $notify->set("read", true);
                     $notify->save();
                     continue;
                 }
                 $notes[] = ['id' => $notify->getObjectId(), 'for' => $notify->get('for')->getObjectId(), 'from' => ['id' => $notify->get('by')->getObjectId(), 'name' => $notify->get('by')->get('name')], 'message' => $notify->get('message')->get('message')];
             }
         }
         $ret = ['status' => "success", 'data' => ['notifications' => $notes]];
         return response()->json($ret);
     } catch (ParseException $ex) {
         $ret = ['status' => 'fail', 'error' => $ex->getMessage()];
         return response()->json($ret);
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:28,代码来源:NotificationServiceController.php

示例2: isCurrentSessionRevocable

 /**
  * Determines whether the current session token is revocable.
  * This method is useful for migrating an existing app to use
  * revocable sessions.
  *
  * @return boolean
  */
 public static function isCurrentSessionRevocable()
 {
     $user = ParseUser::getCurrentUser();
     if ($user) {
         return self::_isRevocable($user->getSessionToken());
     }
 }
开发者ID:rcowick,项目名称:website,代码行数:14,代码来源:ParseSession.php

示例3: dispatch

 /**
  * Dispatch is called before the action, using this to make sure any request to the app without an authenticated
  * user is directed to the signin,
  *
  * @param Request $request
  * @param Response $response
  * @return mixed|\Zend\Http\Response|Response
  */
 public function dispatch(Request $request, Response $response = null)
 {
     $this->user = ParseUser::getCurrentUser();
     if (!$this->user or !isset($_SESSION['todo']['user']) or $this->user->getUsername() !== $_SESSION['todo']['user']) {
         return $this->redirect()->toRoute('auth', ['action' => 'signin']);
     }
     return parent::dispatch($request, $response);
     // TODO: Change the autogenerated stub
 }
开发者ID:mkhuramj,项目名称:ToDo-Web,代码行数:17,代码来源:AppController.php

示例4: retrieveById

 /**
  * Retrieve a user by their unique identifier.
  *
  * @param  mixed $identifier
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null
  */
 public function retrieveById($identifier)
 {
     // check current user exist
     $currentUser = ParseUser::getCurrentUser();
     if ($currentUser->getObjectId() == $identifier) {
         return $currentUser;
     }
     $query = new ParseQuery('_User');
     return $query->get($identifier, true);
 }
开发者ID:redkyo017,项目名称:LaraParse,代码行数:17,代码来源:ParseUserProvider.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $this->current_user = ParseUser::getCurrentUser();
     if (!$this->current_user) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('login');
         }
     }
     return $next($request);
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:19,代码来源:Authenticate.php

示例6: postLogIn

 public function postLogIn(ValidateLoginExpert $request)
 {
     $email = $request->get('email');
     $pass = $request->get('password');
     $user = ParseUser::logIn($email, $pass);
     $query = new ParseQuery("attractions");
     $currentUser = ParseUser::getCurrentUser();
     try {
         $attractions = $query->find();
         return view('expertTemplate.displayAttractions')->with('attractions', $attractions)->with('currentUser', $currentUser);
     } catch (ParseException $ex) {
     }
 }
开发者ID:aktn,项目名称:Laravel_TripPlan,代码行数:13,代码来源:ExpertController.php

示例7: newMessage

 public function newMessage(Request $request)
 {
     $current_user = ParseUser::getCurrentUser();
     $message = $request->input("message");
     $chat_id = $request->input("chat_id");
     $assets = $request->input("assets");
     $utube = $request->input("youtube");
     try {
         $messageObj = new ParseObject("Messages");
         $query = new ParseQuery("ChatRoom");
         $chatRoom = $query->get($chat_id);
         $messageObj->set("message", $message);
         $messageObj->set("user", $current_user);
         $messageObj->set("chatRoom", $chatRoom);
         $messageObj->save();
         $relation = $chatRoom->getRelation("messages");
         $relation->add($messageObj);
         $chatRoom->save();
         if (!empty($assets)) {
             $mrelation = $messageObj->getRelation("asset");
             $crelation = $chatRoom->getRelation("assets");
             foreach ($assets as $asset_id) {
                 $assetQry = new ParseQuery("Assets");
                 $assetObj = $assetQry->get($asset_id);
                 $mrelation->add($assetObj);
                 $crelation->add($assetObj);
             }
             $chatRoom->save();
         }
         if (!empty($utube)) {
             if (preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $utube, $matches)) {
                 $utube = $matches[1];
                 $assetUobj = new ParseObject("Assets");
                 // add the file we saved above
                 $assetUobj->set("youtube", $utube);
                 $assetUobj->save();
                 $mrelation = $messageObj->getRelation("asset");
                 $crelation = $chatRoom->getRelation("assets");
                 $mrelation->add($assetUobj);
                 $crelation->add($assetUobj);
                 $chatRoom->save();
             }
         }
         $messageObj->save();
         $ret = ['status' => "success", 'data' => ['object' => "messages", 'id' => $messageObj->getObjectId(), 'message' => $messageObj->get("message")]];
         return response()->json($ret);
     } catch (ParseException $ex) {
         $ret = ['status' => 'fail', 'error' => $ex->getMessage()];
         return response()->json($ret);
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:51,代码来源:ChatServiceController.php

示例8: login

 public function login($data)
 {
     $app_id = 'yPPe3Uv46pKNnrTc7I6xArFHi8EQ8cdz4Kw3JGkX';
     $rest_key = '7PJB1F4g8aFSv5f8e0gSMwi9Ghv2AeAkTW0O50pe';
     $master_key = 'y95bItd5BI6Btqos1De4m8HZUllSM3HMcOs04WWB';
     try {
         ParseClient::initialize($app_id, $rest_key, $master_key);
         $user = ParseUser::logIn($data["username"], $data["password"]);
         $currentUser = ParseUser::getCurrentUser();
         //die('<pre>'.print_r($currentUser, true));
         return $currentUser;
     } catch (ParseException $e) {
         return false;
     }
 }
开发者ID:JohnOscar-Mendoza,项目名称:lb_cms,代码行数:15,代码来源:Login_model.php

示例9: login

 public function login()
 {
     Hooks::addHook('js', 'Controllers\\auth@js');
     Hooks::addHook('css', 'Controllers\\auth@css');
     // if(Session::get('loggedin')){
     //           Url::redirect();
     //       }
     $currentUser = ParseUser::getCurrentUser();
     if ($currentUser) {
         // do stuff with the user
         Url::redirect();
     } else {
         // show the signup or login page
     }
     //==============Sign Up Manually==========================
     // $user = new ParseUser();
     // $user->set("username", "yoak");
     // $user->set("password", "yoakyoak");
     // $user->set("email", "pacosarin@gmail.com");
     // // other fields can be set just like with ParseObject
     // $user->set("phone", "0909814465");
     // try {
     //   $user->signUp();
     //   // Hooray! Let them use the app now.
     //   $error = 'Hooray! Let them use the app now.';
     // } catch (ParseException $ex) {
     //   // Show the error message somewhere and let the user try again.
     //   echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
     // }
     //==============Sign Up Manually==========================
     if (isset($_POST['submit'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         try {
             $user = ParseUser::logIn($username, $password);
             Url::redirect();
             // Do stuff after successful login.
         } catch (ParseException $ex) {
             // The login failed. Check error to see why.
             $error = "ParseException: " . $ex->getCode() . " " . $ex->getMessage();
         }
     }
     $data['title'] = 'Login';
     View::rendertemplate('header', $data);
     View::render('auth/login', $data, $error);
     View::rendertemplate('footer', $data);
 }
开发者ID:pacozaa,项目名称:simple-mvc-framework-inventory-parse,代码行数:47,代码来源:auth.php

示例10: testRevocableSession

 public function testRevocableSession()
 {
     ParseClient::enableRevocableSessions();
     $user = new ParseUser();
     $user->setUsername("username");
     $user->setPassword("password");
     $user->signUp();
     $session = ParseSession::getCurrentSession();
     $this->assertEquals($user->getSessionToken(), $session->getSessionToken());
     $this->assertTrue($session->isCurrentSessionRevocable());
     ParseUser::logOut();
     ParseUser::logIn("username", "password");
     $session = ParseSession::getCurrentSession();
     $this->assertEquals(ParseUser::getCurrentUser()->getSessionToken(), $session->getSessionToken());
     $this->assertTrue($session->isCurrentSessionRevocable());
     $sessionToken = $session->getSessionToken();
     ParseUser::logOut();
     $this->setExpectedException('Parse\\ParseException', 'invalid session token');
     ParseUser::become($sessionToken);
 }
开发者ID:louk,项目名称:https---github.com-soninod-Hello,代码行数:20,代码来源:ParseSessionTest.php

示例11: save

 public function save(Request $request)
 {
     $current_user = ParseUser::getCurrentUser();
     $name = $request->input('name');
     $assetId = $request->input('assetId');
     $current_user->set('name', $name);
     try {
         if (!empty($assetId)) {
             $query = new ParseQuery("Assets");
             $asset = $query->get($assetId);
             if (!empty($asset)) {
                 $current_user->set('image', $asset->get('file'));
             }
         }
         $current_user->save();
     } catch (\Exception $ex) {
         echo 'Failed to create new object, with error message: ' . $ex->getMessage();
     }
     return redirect()->route('profile');
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:20,代码来源:ProfileController.php

示例12: showUploader

 public function showUploader($roomId, Request $request)
 {
     $current_user = ParseUser::getCurrentUser();
     if (!$current_user) {
         return redirect()->route('login');
     }
     $message = $request->input('msg');
     Html\Assets::addLink(Html\Link::Css('/vendor/dropzone/dropzone.css'));
     Html\Assets::addLink(Html\Link::Css(elixir('css/default.css')));
     Html\Assets::addLink(Html\Link::Script('//www.parsecdn.com/js/parse-1.6.7.min.js'));
     Html\Assets::addLink(Html\Link::Script('/vendor/dropzone/dropzone.js'));
     Html\Assets::addLink(Html\Link::Script(elixir('scripts/chatUploader.js')));
     Html\Assets::addMetaTag(Html\Meta::Tag('description', ''));
     $query = new ParseQuery("ChatRoom");
     $chatObj = $query->get($roomId);
     $renderData = $this->getRenderData($request);
     $renderData['user'] = $current_user;
     $renderData['chatObj'] = $chatObj;
     $renderData['message'] = $message;
     return view('chatUploader', $renderData);
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:21,代码来源:ChatController.php

示例13: getIndex

 /**
  * Show the profile for the given user.
  *
  * @param  int  $id
  * @return Response
  */
 public function getIndex()
 {
     ParseClient::initialize(env('PARSE_APP_ID'), env('ARSE_REST_KEY'), env('PARSE_MASTER_KEY'));
     $user = new ParseUser();
     $user->setUsername("foo");
     $user->setPassword("Q2w#4!o)df");
     try {
         $user->signUp();
         dd(1112);
     } catch (ParseException $ex) {
         echo $ex->getMessage() . "<br>";
     }
     // Login
     try {
         $user = ParseUser::logIn("foo", "Q2w#4!o)df");
     } catch (ParseException $ex) {
         echo $ex->getMessage();
     }
     // Current user
     $user = ParseUser::getCurrentUser();
     dd($user);
 }
开发者ID:varyan,项目名称:tratesTrates,代码行数:28,代码来源:TestController.php

示例14: secOwnerBeacUnAssQuery

 public function secOwnerBeacUnAssQuery($venueId)
 {
     $user = ParseUser::getCurrentUser();
     $roleCheck = $user->get("role");
     $roleCheck->fetch();
     $role = $roleCheck->get("name");
     $beacon_info = [];
     $outletCheck = new ParseObject("Outlets", $venueId);
     $query = new ParseQuery("Beacons");
     $query->equalTo("outlet", $outletCheck);
     $query->equalTo("isSectionAssigned", true);
     $result = $query->find();
     for ($i = 0; $i < count($result); $i++) {
         $object = $result[$i];
         $beacon_info[$object->getObjectId()] = $object->get('name');
     }
     return $beacon_info;
 }
开发者ID:Lawrence94,项目名称:sme4me,代码行数:18,代码来源:Editcompquery_model.php

示例15: find

 /**
  * Execute a find query and return the results.
  *
  * @param bool $useMasterKey
  *
  * @return ParseObject[]
  */
 public function find($useMasterKey = false)
 {
     $sessionToken = null;
     if (ParseUser::getCurrentUser()) {
         $sessionToken = ParseUser::getCurrentUser()->getSessionToken();
     }
     $queryString = $this->buildQueryString($this->_getOptions());
     $result = ParseClient::_request('GET', 'classes/' . $this->className . '?' . $queryString, $sessionToken, null, $useMasterKey);
     $output = [];
     foreach ($result['results'] as $row) {
         $obj = ParseObject::create($this->className, $row['objectId']);
         $obj->_mergeAfterFetchWithSelectedKeys($row, $this->selectedKeys);
         $output[] = $obj;
     }
     return $output;
 }
开发者ID:ParseServer,项目名称:parse-php-sdk,代码行数:23,代码来源:ParseQuery.php


注:本文中的Parse\ParseUser::getCurrentUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。