public function setUp() { Helper::clearClass('_User'); Helper::clearClass('_Role'); Helper::clearClass('Things'); ParseUser::logOut(); }
/** * Cierra la sesion del usuario actual * @return objeto json */ public static function cerrarSesion() { try { ParseUser::logOut(); return json_encode(['sesion' => 1]); } catch (Exception $ex) { return json_encode(['sesion' => 0, 'error' => $ex->getMessage()]); } }
/** * Expects a post with email / password (or the form is just shown). Attempts to log the user in, then redirects * to the app controller. If the login fails, redirects to itself (PRG) with a flash message. */ public function signinAction() { ParseUser::logOut(); if (!$this->request instanceof Request or !$this->request->isPost()) { return; //nothing to do } try { $user = ParseUser::logIn($this->request->getPost('email'), $this->request->getPost('password')); $_SESSION['todo']['user'] = $user->getUsername(); $this->redirect()->toRoute('app'); } catch (ParseException $e) { $this->flashMessenger()->addErrorMessage($e->getMessage()); $this->redirect()->toRoute('auth', ['action' => 'signin']); } }
public function user_logut($username, $password) { try { $user = ParseUser::logIn($username, $password); $user->set("remember_token", ""); $user->save(); } catch (ParseException $error) { return $error->getMessage(); } ParseUser::logOut(); $currentUser = ParseUser::getCurrentUser(); if (is_null($currentUser)) { return true; } else { return false; } }
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); }
<?php include '../parse.php'; use Parse\ParseUser; ParseUser::logOut();
public function dtestUserLoadedFromStorageFromLogIn() { ParseTestHelper::clearClass(ParseUser::$parseClassName); $fosco = new ParseUser(); $fosco->setUsername('fosco'); $fosco->setPassword('password'); $fosco->signUp(); $id = $fosco->getObjectId(); $this->assertNotNull($id); ParseUser::logOut(); ParseUser::_clearCurrentUserVariable(); $current = ParseUser::getCurrentUser(); $this->assertNull($current); ParseUser::logIn("fosco", "password"); $current = ParseUser::getCurrentUser(); $this->assertEquals($id, $current->getObjectId()); ParseUser::_clearCurrentUserVariable(); $current = ParseUser::getCurrentUser(); $this->assertEquals($id, $current->getObjectId()); }
public function logoutUser($params) { ParseUser::logOut(); }
public function logout() { // Session::destroy(); ParseUser::logOut(); Url::redirect(); }
public function doAddManager($adminfName, $adminlName, $adminMail, $adminPass, $adminPerm) { # code... $currentUser = ParseUser::getCurrentUser(); $dbusername = $this->session->userdata('username'); $userDetails = $this->db->get_where('userdetails', ['username' => $dbusername])->row(); $dbgetusername = $userDetails->username; $dbgetpassword = $userDetails->password; $user = new ParseUser(); $user->set("username", $adminMail); $user->set("password", $adminPass); $user->set("email", $adminMail); $user->set("creator", $currentUser); // other fields can be set just like with ParseObject $user->set("firstName", $adminfName); $user->set("lastName", $adminlName); try { // Query for the role to be assigned to the owner of the company $role = new ParseObject("_Role"); $query = new ParseQuery("_Role"); $role = $query->get($adminPerm); $user->signUp(); $role->getUsers()->add($user); $user->set("role", $role); $role->save(); $user->save(); ParseUser::logOut(); $prevUser = ParseUser::logIn($dbgetusername, $dbgetpassword); // Hooray! Let them use the app now. return ['status' => true]; } catch (ParseException $ex) { // Show the error message somewhere and let the user try again. // echo "Error: " . $ex->getCode() . " " . $ex->getMessage(); return ['status' => false, 'parseMsg' => $ex->getMessage()]; } }
public function processLogout(Request $request) { $request->session()->set('lastAction', ''); ParseUser::logOut(); return redirect('/'); }
public function logOut(Request $request) { \Session::forget('username'); ParseUser::logOut(); return redirect('/'); }
public function index() { // This only happens if there was a post request from the lockscreen form. if ($this->input->server('REQUEST_METHOD') == 'POST') { //declare variables //holding boolean for error checking $status1 = true; // get username from login form // this was made hidden in the form so that the user doesn't see it. $username = $this->input->post('txtusername'); // get password from login form $password = $this->input->post('txtpassword'); // set validation rules $this->form_validation->set_rules('txtusername', 'Email', 'required|min_length[5]|valid_email|trim'); $this->form_validation->set_rules('txtpassword', 'Password', 'required'); // check validation // If there was an error during validation, this runs. if ($this->form_validation->run() == FALSE) { $data = array('displayData' => 'display:show'); $this->load->view('lockscreen/lockscreen_company', $data); } else { // login using the login model $loginParse = $this->login->doLogin($username, $password); // check if the status message from the login operation is false. if (!$loginParse['status']) { $status1 = false; } // do something if the status is false(e.g, show an error message). if (!$status1) { notify('danger', $loginParse['parseMsg'], 'company/Lockscreen'); } else { echo "Logging you in..."; //$this->session->sess_destroy(); $userDetails = ['firstName', 'lastName', 'username']; //$this->session->unset_userdata($userDetails); redirect('company/Dashboard', 'refresh'); } } // This happens if there is a normal navigation to the page } else { //$this->menu_header(); $currentUser = ParseUser::getCurrentUser(); $firstName = ''; $lastName = ''; $username = ''; $userDetails = ['firstName', 'lastName', 'username']; if (!$this->session->userdata('firstName')) { echo 'session totally destroyed, sorry.'; redirect('company/Login'); } else { if ($currentUser) { // do stuff with the user $firstName = $currentUser->get("firstName"); $lastName = $currentUser->get("lastName"); $username = $currentUser->get("username"); $userDetails = array('firstName' => $firstName, 'lastName' => $lastName, 'username' => $username); $this->session->set_userdata($userDetails); //$currentUser = ParseUser::getCurrentUser(); //if ($currentUser){ // log the user out ParseUser::logOut(); // load lockscreen view with the details needed for login // which has already been set in the $adminName array (which excludes the password for obvious reasons). } $adminDetails = ['firstName' => $this->session->userdata('firstName'), 'lastName' => $this->session->userdata('lastName'), 'username' => $this->session->userdata('username'), 'displayData' => 'display:none']; $this->load->view('lockscreen/lockscreen_company', $adminDetails); // else{ // // go to the main login page if the user is not in session // redirect('admin/Login','refresh'); // // destroy the codeIgniter session set with user details in the menu_header() function. // $this->session->sess_destroy(); // } // $data = array( // 'displayData' => 'display:none', // 'firstName' => $this->session->userdata('firstName'), // 'lastName' => $this->session->userdata('lastName'), // 'username' => $this->session->userdata('username') // ); // $this->load->view('lockscreen/lockscreen', $data); } } }
public function testACLSharingWithAnotherUser() { $bob = new ParseUser(); $bob->setUsername('bob'); $bob->setPassword('pass'); $bob->signUp(); $bob->logOut(); $alice = new ParseUser(); $alice->setUsername('alice'); $alice->setPassword('wonderland'); $alice->signUp(); $object = ParseObject::create('Object'); $acl = ParseACL::createACLWithUser($alice); $acl->setUserReadAccess($bob, true); $acl->setUserWriteAccess($bob, true); $object->setACL($acl); $object->save(); $this->assertTrue($object->getACL()->getUserReadAccess($alice)); $this->assertTrue($object->getACL()->getUserWriteAccess($alice)); $this->assertTrue($object->getACL()->getUserReadAccess($bob)); $this->assertTrue($object->getACL()->getUserWriteAccess($bob)); $this->assertFalse($object->getACL()->getPublicReadAccess()); $this->assertFalse($object->getACL()->getPublicWriteAccess()); ParseUser::logOut(); $query = new ParseQuery('Object'); try { $query->get($object->getObjectId()); $this->fail('public should be unable to get'); } catch (\Parse\ParseException $e) { } $this->assertEquals(0, count($query->find())); $object->set('foo', 'bar'); try { $object->save(); $this->fail('update should fail with object not found'); } catch (\Parse\ParseException $e) { } try { $object->destroy(); $this->fail('delete should fail with object not found'); } catch (\Parse\ParseException $e) { } ParseUser::logIn('bob', 'pass'); $query = new ParseQuery('Object'); $result = $query->get($object->getObjectId()); $this->assertNotNull($result); $this->assertTrue($result->getACL()->getUserReadAccess($alice)); $this->assertTrue($result->getACL()->getUserWriteAccess($alice)); $this->assertTrue($result->getACL()->getUserReadAccess($bob)); $this->assertTrue($result->getACL()->getUserWriteAccess($bob)); $this->assertFalse($result->getACL()->getPublicReadAccess()); $this->assertFalse($result->getACL()->getPublicWriteAccess()); $this->assertEquals(1, count($query->find())); $object->set('foo', 'bar'); $object->save(); $object->destroy(); }
public function logOut() { ParseUser::logOut(); }