public function defaultAction() { $memcache = new Memcache(); $memcache->flush(); $usuario = new Usuario(); $daoUsuario = DAOFactory::getUsuarioDAO(); /** @var $user User */ $user = UserService::getCurrentUser(); if (isset($user)) { $usuarioBD = $daoUsuario->queryByGoogle($user->getUserId()); if (!$usuarioBD) { // No existe el usuario $usuario->google = $user->getUserId(); $usuario->correo = $user->getEmail(); $usuario->nombre = $user->getNickname(); $daoUsuario->insert($usuario); } else { $usuario = $usuarioBD; } $_SESSION['logoutUrl'] = UserService::createLogoutUrl('/index/closeSession'); $_SESSION['usuario'] = $usuario; include 'vod/index.php'; } else { $this->login(); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user = UserService::getCurrentUser(); if (!isset($user)) { return redirect(UserService::createLoginUrl('/')); } return $next($request); }
public function __construct() { $this->middleware('appEngineAuth', ['except' => ['message']]); $this->app = app(); $this->user = UserService::getCurrentUser(); $this->credentialStore = new CredentialStore(); $this->watchStore = new WatchStore(); $this->googleClient = $this->createGoogleClient(); }
/** * The very very first page. */ public function getRoot() { $user = UserService::getCurrentUser(); if (isset($user)) { return Redirect::to('/home'); } else { $url = UserService::createLoginUrl('/home'); return View::make('home.index')->with('url', $url); } }
public function index() { $user = UserService::getCurrentUser(); if (isset($user)) { echo 'Welcome, ' . $user->getNickname(); if (UserService::isCurrentUserAdmin()) { $data = array('title' => 'Admin Section', 'hello' => 'Hello admin...', 'content' => 'You are accessing the backend now'); $this->render("admin.html", $data); } else { header('Location: ' . UserService::createLoginURL($_SERVER['REQUEST_URI'])); } } }
<?php use google\appengine\api\users\User; use google\appengine\api\users\UserService; $user = UserService::getCurrentUser(); session_start(); if ($_SESSION["loggedIn"] != true) { if (isset($user)) { echo sprintf('Your current Google account, %s, does not have access to this application (<a href="%s">sign out</a>)', $user->getNickname(), UserService::createLogoutUrl('/')); } exit; } else { if (isset($user)) { if ($user->getNickname()) { $mailTim = '<EMAIL_RESIDENT_1>'; } $mailJetse = '<EMAIL_RESIDENT_2>'; $mailMees = '<EMAIL_RESIDENT_3>'; if (strcmp(htmlspecialchars($user->getNickname()), $mailTim) == 0) { $nameString = "Tim"; } else { if (strcmp(htmlspecialchars($user->getNickname()), $mailJetse) == 0) { $nameString = "Jetse"; } else { if (strcmp(htmlspecialchars($user->getNickname()), $mailMees) == 0) { $nameString = "Mees"; } } } } }
<body> <?php use google\appengine\api\users\User; use google\appengine\api\users\UserService; use google\appengine\api\cloud_storage\CloudStorageTools; require_once __DIR__ . '/../rest/models/userModel.php'; require_once __DIR__ . '/../rest/models/eventModel.php'; require_once __DIR__ . '/../rest/models/guestModel.php'; $session_token = md5('admin_session'); $session_path = __DIR__ . '/../../media/sessions'; if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) { require_once 'google/appengine/api/users/User.php'; require_once 'google/appengine/api/users/UserService.php'; require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php'; $mail = UserService::getCurrentUser()->getNickname(); $session_token = md5($mail); $user = new userModel(); $u = $user->find_one_by_email(strtolower($mail)); if (isset($u['id'])) { Bootstrap::$main->session('user', $u); Bootstrap::$main->user = $u; Bootstrap::$main->session('time_delta', $u['delta']); echo '<h1><a href="/admin/">' . $u['firstname'] . ' ' . $u['lastname'] . '</a></h1>'; } $session_path = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/sessions'; } else { echo "<h1>Witaj</h1>"; @mkdir($session_path, 0755); } $session_file = "{$session_path}/{$session_token}.sess";
public function getSessionUserStamp(){ $user = UserService::getCurrentUser(); $UserStamp=$user->getEmail(); return $UserStamp; }
public function __construct() { $this->user = UserService::getCurrentUser(); $this->is_admin = UserService::isCurrentUserAdmin(); }
public function testGetCurrentUser() { putenv('AUTH_DOMAIN=example.com'); putenv('USER_EMAIL=bill@example.com'); $expectedUser = new User("*****@*****.**"); $user = UserService::getCurrentUser(); $this->assertEquals($expectedUser, $user); $this->assertSame("bill", $user->getNickname()); $this->assertSame("*****@*****.**", $user->getEmail()); $this->assertSame(null, $user->getUserId()); $this->assertSame("example.com", $user->getAuthDomain()); $this->assertSame(null, $user->getFederatedIdentity()); $this->assertSame(null, $user->getFederatedProvider()); }
/** * @dataProvider getCurrentUserDataProvider */ public function testGetCurrentUser($auth_domain_env, $user_email_env) { putenv($auth_domain_env . '=example.com'); putenv($user_email_env . '=bill@example.com'); $expectedUser = new User("*****@*****.**"); $user = UserService::getCurrentUser(); $this->assertEquals($expectedUser, $user); $this->assertSame("bill", $user->getNickname()); $this->assertSame("*****@*****.**", $user->getEmail()); $this->assertSame(null, $user->getUserId()); $this->assertSame("example.com", $user->getAuthDomain()); $this->assertSame(null, $user->getFederatedIdentity()); $this->assertSame(null, $user->getFederatedProvider()); // Clear environment variables. putenv($auth_domain_env); putenv($user_email_env); }
public function register(Application $app) { $app['gae.auth'] = $app->protect(function () use($app) { return new Auth($app, UserService::getCurrentUser()); }); }
require_once __DIR__ . '/../lib/Doctrine/Doctrine.php'; spl_autoload_register(array('Doctrine', 'autoload')); use google\appengine\api\users\User; use google\appengine\api\users\UserService; use google\appengine\api\cloud_storage\CloudStorageTools; if (isset($_SERVER['REMOTE_ADDR'])) { $title = 'Migration'; $menu = 'migrate'; include __DIR__ . '/../base.php'; include __DIR__ . '/../head.php'; } if (isset($_SERVER['HTTP_HOST'])) { if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) { require_once 'google/appengine/api/users/User.php'; require_once 'google/appengine/api/users/UserService.php'; $google_user = UserService::getCurrentUser(); $config_file = str_replace('~', '-', $_SERVER['APPLICATION_ID']); } else { $config_file = strtolower($_SERVER['HTTP_HOST']); } } else { $config_file = 'local'; if (isset($argv[1])) { $_REQUEST['ver'] = $argv[1]; } } $f = __DIR__ . '/../../rest/config/application.json'; if (isset($_SERVER['REMOTE_ADDR'])) { echo "Configuration from {$f}<br/>"; } $config = json_decode(file_get_contents($f), true);
<?php require_once 'google/appengine/api/users/UserService.php'; use google\appengine\api\users\UserService; $email = UserService::getCurrentUser()->email; $domain = explode("@", $email)[1]; if ($domain == "google.com") { ?> <!DOCTYPE html> <html> <head> <title>Administration tools - Measuring Value Application</title> <link rel="stylesheet" type="text/css" href="/styles/main.css"> <link rel="stylesheet" type="text/css" href="/styles/adm.css"> <link rel="stylesheet" type="text/css" href="/styles/startup.css"> <link rel="stylesheet" type="text/css" href="/styles/flipper.css"> <script src="/scripts/lib/jquery-2.1.1.min.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <script src="/scripts/lib/jquery.velocity.min.js"></script> <script src="/scripts/settings.js"></script> <!-- libraries --> <script src="/scripts/lib/flipper.js"></script> <script src="/scripts/lib/sandbox.js"></script> <script src="/scripts/lib/stripe.js"></script> <!-- utilities for managing google drive actions --> <script src="/scripts/utils/serve_json.js"></script> <!-- object Result -->