本文整理汇总了PHP中Parse\ParseUser类的典型用法代码示例。如果您正苦于以下问题:PHP ParseUser类的具体用法?PHP ParseUser怎么用?PHP ParseUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParseUser类的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: 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
}
示例3: register
function register($name, $email, $password, $teacher)
{
$user = new ParseUser();
$user->set("username", $email);
$user->set("email", $email);
$user->set("password", $password);
$user->set("name", $name);
if ($teacher == "true") {
$user->set("Teacher", true);
} else {
$user->set("Teacher", false);
}
try {
$user->signUp();
$user->save();
if ($teacher == "true") {
header("Location: profile.php");
} else {
header("Location: howToLearn.php");
}
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
}
}
示例4: signup
function signup()
{
$username = $_POST["id"];
$user = new ParseUser();
$user->set("username", $username);
$user->set("password", $_POST["pass"]);
$user->set("email", $username . "@example.com");
try {
$user->signUp();
// 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();
}
}
示例5: 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());
}
}
示例6: 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);
}
示例7: 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);
}
示例8: authenticated
/**
* Show the form for creating a new resource.
*
* @return Bool
*/
public static function authenticated()
{
try {
ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
$session = Cache::get('sessionToken', 'default');
$user = ParseUser::become($session);
return true;
} catch (ParseException $error) {
return false;
}
}
示例9: 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);
}
示例10: resetPasswordAux
function resetPasswordAux($userName)
{
try {
console . log("entrei");
window . alert("Email enviado");
ParseUser::requestPasswordReset($userName);
window . alert("Email enviado");
// Password reset request was sent successfully
} catch (ParseException $ex) {
// Password reset failed, check the exception message
}
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
Log::info("PARSE AUTH");
try {
ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
$session = Cache::get('sessionToken', 'default');
$user = ParseUser::become($session);
return $next($request);
} catch (ParseException $error) {
Log::info("PARSE AUTH ERROR: " . $error);
return new RedirectResponse(url('/login'));
}
}
示例12: 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) {
}
}
示例13: enviarPush
/**
Envia la notificacion a cierto usuario
**/
function enviarPush()
{
$_strName = $_POST['nombreUsuario'];
$_strMenssage = $_POST['send'];
// Find users near a given username
$userQuery = ParseUser::query();
$userQuery->equalTo("username", $_strName);
// Find devices associated with these users
$pushQuery = ParseInstallation::query();
$pushQuery->matchesQuery('Usuarios', $userQuery);
// Send push notification to query
ParsePush::send(array("where" => $pushQuery, "data" => array("alert" => "{$_strMenssage}")));
}
示例14: get_user_data
public function get_user_data($username, $credentials)
{
ParseClient::initialize($credentials->app_id, $credentials->rest_key, $credentials->master_key);
$query = ParseUser::query();
$query->equalTo('username', $username);
$result = $query->find();
$user = $result[0];
$data = new stdClass();
$data->fullName = $user->get("fullName");
$data->avatar = $user->get("avatar");
$data->title = $user->get("title");
return $data;
}
示例15: logOut
/**
* LOGOUT A USER
*
* @return void
*/
public function logOut()
{
try {
ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
$session = Cache::get('sessionToken', 'default');
$user = ParseUser::become($session);
Cache::forget('sessionToken');
$user->logOut();
return Redirect::to('login');
} catch (ParseException $error) {
dd($error);
}
}