本文整理汇总了PHP中Parse\ParseUser::become方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseUser::become方法的具体用法?PHP ParseUser::become怎么用?PHP ParseUser::become使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseUser
的用法示例。
在下文中一共展示了ParseUser::become方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: 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'));
}
}
示例3: 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);
}
}
示例4: testBecome
public function testBecome()
{
$user = new ParseUser();
$user->setUsername("asdf");
$user->setPassword("zxcv");
$user->signUp();
$this->assertEquals(ParseUser::getCurrentUser(), $user);
$sessionToken = $user->getSessionToken();
$newUser = ParseUser::become($sessionToken);
$this->assertEquals(ParseUser::getCurrentUser(), $newUser);
$this->assertEquals("asdf", $newUser->get('username'));
$this->setExpectedException('Parse\\ParseException', 'invalid session');
$failUser = ParseUser::become('garbage_token');
}
示例5: enviarAtualizacao
/**
* Envia push de atualizaçao.
*
* @return Response
*/
public function enviarAtualizacao()
{
try {
ParseClient::initialize('YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0', 'zNGQwg11i4fQRhGUCZIR777A8VRWjCqe3BQeZgDI', '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o');
$session = Cache::get('sessionToken', 'default');
$usuario = ParseUser::become($session);
$texto = Input::get('texto');
$atualizacaoQuery = new ParseQuery("Atualizacao");
$atualizacaoQuery->descending("numero");
$ultimaAtualizacao = $atualizacaoQuery->first();
$novoNumero = $ultimaAtualizacao->get('numero') + 1;
$novaAtualizacao = new ParseObject("Atualizacao");
$novaAtualizacao->set('numero', $novoNumero);
$novaAtualizacao->set('usuario', $usuario);
$novaAtualizacao->set('texto', $texto);
$novaAtualizacao->save();
// $fields = array('Accept'=>'application/json',
// 'X-Parse-Application-Id' => 'YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0',
// 'X-Parse-Master-Key' => '4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o');
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, 'https://api.parse.com/1/jobs/jobTeste');
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
// curl_setopt($ch, CURLOPT_HEADER, $fields);
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// // curl_setopt(CURLOPT_USERPWD, 'XXXXXX');
// $result = curl_exec($ch);
// curl_close($ch);
// $cmd='curl -X POST \
// -H \"X-Parse-Application-Id: YZzX02HIZ0xnl2XgzYRHB9QRwYr6FBgWrDUYl5w0\" \
// -H \"X-Parse-Master-Key: 4neCCcchvafqvgZlnVu0c4q3s3nsmh9n5tYV0x2o\" \
// -H \"Content-Type: application/json\" \
// -d \"{\"plan\":\"paid\"}\" \
// https://api.parse.com/1/jobs/jobTeste';
// Log::info($cmd);
// exec($cmd,$result);
Log::info("CHEGUEI NEGAO");
// Log::info($result);
return 200;
} catch (ParseException $error) {
return $error;
}
}
示例6: 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);
}
示例7: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
try {
ParseClient::initialize(env('PARSE_ID', 'fuck'), env('PARSE_REST', 'fuck'), env('PARSE_MASTER', 'fuck'));
$session = Cache::get('sessionToken', 'default');
$user = ParseUser::become($session);
$nome = Input::get('nome');
$especialidadeId = Input::get('especialidadeId');
$especQuery = new ParseQuery("Especialidade");
$especialidade = $especQuery->get($especialidadeId);
$protocolo = ParseObject::create("Protocolo");
$protocolo->set('nome', $nome);
$protocolo->set('especialidade', $especialidade);
$protocolo->save();
$id = $protocolo->getObjectId();
return $id;
} catch (ParseException $error) {
return $error;
}
}
示例8: isValidSessionToken
/**
* Validating user session token
* If the session token matches the api key user, it is a valid token
* @param String $session_token user session token
* @param String $api_key user api key
* @return boolean
*/
public function isValidSessionToken($session_token, $api_key)
{
// Using already validated $api_key, obtain corresponding user object
$query = ParseUser::query();
$query->equalTo("apiKey", $api_key);
$results = $query->find();
if (count($results) > 0) {
$userObj = $results[0];
} else {
return FALSE;
}
try {
// Become user that has this session token
// Only was to query back the user that they are
// If no user is found with this token, parse error
$thisUser = ParseUser::become($session_token);
$query = ParseSession::query();
$query->equalTo("user", $userObj);
$results = $query->find();
if (count($results) > 0) {
return TRUE;
} else {
return FALSE;
}
} catch (Parse\ParseException $error) {
return FALSE;
}
}