gonzalo123 / silex-gae-login-provider
Google App Engine Login provider for Silex
dev-master
2013-05-19 16:39 UTC
Requires
- php: >=5.4.0
- silex/silex: 1.0.*@dev
This package is not auto-updated.
Last update: 2024-12-02 15:47:15 UTC
README
Google App Engine Login provider for Silex
Usage example:
Google app engine configuration:
application: silexgae version: 1 runtime: php api_version: 1 threadsafe: true handlers: - url: .* script: main.php
Silex Application:
<?php require_once __DIR__ . '/vendor/autoload.php'; use Silex\Application; use Gae\LoginProvider; use Gae\Auth; $app = new Application(); $app->register(new LoginProvider(), array( 'auth.onlogin.callback.url' => '/private', 'auth.onlogout.callback.url' => '/loggedOut', )); /** @var Auth $auth */ $auth = $app['gae.auth'](); $app->get('/', function () use ($app, $auth) { return $auth->isLogged() ? $app->redirect("/private") : "<a href='" . $auth->getLoginUrl() . "'>login</a>"; }); $app->get('/private', function () use ($app, $auth) { return $auth->isLogged() ? "Hello " . $auth->getUser()->getNickname() . " <a href='" . $auth->getLogoutUrl() . "'>logout</a>" : $auth->getRedirectToLogin(); }); $app->get('/loggedOut', function () use ($app) { return "Thank you!"; }); $app->run();