本文整理汇总了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);
}
}
示例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());
}
}
示例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
}
示例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);
}
示例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);
}
示例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) {
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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');
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}