Skip to content
This repository has been archived by the owner on Nov 18, 2018. It is now read-only.

Commit

Permalink
Updated the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorinPopaCodes committed Oct 14, 2013
1 parent f047e94 commit 361c026
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
),
)
)
);
);

// Enable extension
$app->register(new OpauthExtension());

// Listen for events
$app->dispatcher->addListener(OpauthExtension::EVENT_ERROR, function($e) {
$app->on(OpauthExtension::EVENT_ERROR, function($e) {
$this->log->error('Auth error: ' . $e['message'], ['response' => $e->getSubject()]);
$e->setArgument('result', $this->redirect('/'));
});

$app->dispatcher->addListener(OpauthExtension::EVENT_SUCCESS, function($e) {
$app->on(OpauthExtension::EVENT_SUCCESS, function($e) {
$response = $e->getSubject();

/*
/*
find/create a user, oauth response is in $response and it's already validated!
store the user in the session
*/
Expand Down Expand Up @@ -69,7 +69,7 @@ To login using opauth use /login/PROVIDER, or use `opauth_default_login` route w

```

By default, users will be looked up by username "provider:uid".
By default, users will be looked up by username "provider:uid".

You should extend your user provider to handle OPauth results correctly by implementing `OpauthUserProviderInterface`.

28 changes: 23 additions & 5 deletions example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@

$app = new Application();

$app['debug'] = true;

$app['opauth'] = array(
'login' => '/auth/login',
'login' => '/auth/login', // Generates a path /auth/login/{strategy}
'callback' => '/auth/callback',
'config' => array(
'security_salt' => 'LDFmiilYf8Fyw5W10rxx4W1KsVrieQCnpBzzpTBWA5vJidQKDx8pMJbmw28R1C4m',
'security_salt' => '_SECURE_RANDOM_SALT_',
'Strategy' => array(
'Facebook' => array(
'Facebook' => array( // Is available at /auth/login/facebook
'app_id' => 'APP_ID',
'app_secret' => 'APP_SECRET'
'app_secret' => 'APP_SECRETE'
),
)
)
Expand All @@ -24,4 +26,20 @@
$app->register(new OpauthExtension());


$app->run();
// Listen for events
$app->on(OpauthExtension::EVENT_ERROR, function($e) {
$this->log->error('Auth error: ' . $e['message'], ['response' => $e->getSubject()]);
$e->setArgument('result', $this->redirect('/'));
});

$app->on(OpauthExtension::EVENT_SUCCESS, function($e) {
$response = $e->getSubject();

/*
find/create a user, oauth response is in $response and it's already validated!
store the user in the session
*/

$e->setArgument('result', $this->redirect('/'));
});
$app->run();

0 comments on commit 361c026

Please sign in to comment.