Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Commit

Permalink
update demo auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Feb 16, 2017
1 parent 1a54ef7 commit ee6e350
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
4 changes: 2 additions & 2 deletions demo/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* @var \Deimos\Auth\Auth $auth
*/

$password = $auth->domain()->provider('domainPassword');
$password = $auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->provider('domainPassword');
$password->login($_POST['login'], $_POST['password']);

$provider = isset($_POST['withCookie']) ? 'domainCookie' : 'domainSession';

$auth->domain()->provider($provider)->persist();
$auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->provider($provider)->persist();

header('location: ./');
die;
Expand Down
28 changes: 28 additions & 0 deletions demo/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@

$config = [

'demo' => [

'domainCookie' => [
'type' => 'cookie',
'persist' => 'domainPassword',

'tokens' => [
'model' => 'token',
'expires' => 3600 * 24 * 14
]
],

'domainSession' => [
'type' => 'session',
'persist' => 'domainPassword'
],

'domainPassword' => [
'type' => 'password',
'model' => 'user',

'loginFields' => ['email', 'login'],
'hashField' => 'password'
]

],


'default' => [

'domainCookie' => [
Expand Down
4 changes: 2 additions & 2 deletions demo/forgot.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

include_once __DIR__ . '/bootstrap.php';

if ($auth->domain()->user())
if ($auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->user())
{
$auth->domain()->forgetUser();
$auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->forgetUser();

header('location: ./');
die;
Expand Down
4 changes: 2 additions & 2 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

include_once __DIR__ . '/bootstrap.php';

if ($auth->domain()->user())
if ($auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->user())
{
echo 'Добро пожаловать! ', '[<a href="forgot.php">выход</a>]';

var_dump($auth->domain()->user()->asArray());
var_dump($auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->user()->asArray());
die;
}

Expand Down
2 changes: 1 addition & 1 deletion demo/reg.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @var \Deimos\Auth\Auth $auth
*/

$password = $auth->domain()->provider('domainPassword');
$password = $auth->domain(isset($_GET['domain']) ? $_GET['domain'] : 'default')->provider('domainPassword');

$orm->create('user', [
'email' => $_POST['login'] . '@deimos',
Expand Down

0 comments on commit ee6e350

Please sign in to comment.