Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
Signed-off-by: Suhayb El Wardany <[email protected]>
  • Loading branch information
suwardany committed May 14, 2014
1 parent fbdc4a6 commit 9edfc69
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 613 deletions.
69 changes: 69 additions & 0 deletions app/commands/DemoInstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class DemoInstallCommand extends Command {

/**
* The console command name.
*
* @var string
*/
protected $name = 'demo:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install demo.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->call('migrate');
$this->call('migrate:reset');
$this->call('migrate', ['--package' => 'cartalyst/sentry']);
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(

);
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(

);
}

}
4 changes: 2 additions & 2 deletions app/config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@
|
*/

'pretend' => false,
'pretend' => true,

);
);
4 changes: 3 additions & 1 deletion app/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public function processRegistration()
{
$activation = Activation::create($user);

$sent = Mail::send('sentry.emails.activate', compact('user', 'activation'), function($m) use ($user)
$code = $activation->code;

$sent = Mail::send('sentry.emails.activate', compact('user', 'code'), function($m) use ($user)
{
$m->to($user->email)->subject('Activate Your Account');
});
Expand Down
32 changes: 19 additions & 13 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
|
*/

// Disable checkpoints (throttling, activation) for demo purposes
Sentry::disableCheckpoints();

Route::get('logout', function()
{
Sentry::logout();
Expand Down Expand Up @@ -40,6 +43,11 @@

Route::get('/', function()
{
if (Sentry::check())
{
return Redirect::to('account');
}

return View::make('sentry/index');
});

Expand All @@ -49,8 +57,6 @@
Route::get('register', 'AuthController@register');
Route::post('register', 'AuthController@processRegistration');



Route::get('wait', function()
{
return View::make('sentry.wait');
Expand Down Expand Up @@ -78,6 +84,11 @@

$activation = Activation::exists($user) ?: Activation::create($user);

// This is used for the demo, usually you would want
// to activate the account through the link you
// receive in the activation email
Activation::complete($user, $activation->code);

$code = $activation->code;

$sent = Mail::send('sentry.emails.activate', compact('user', 'code'), function($m) use ($user)
Expand All @@ -90,7 +101,7 @@
return Redirect::to('register')->withErrors('Failed to send activation email.');
}

return Redirect::to('wait');
return Redirect::to('account');
})->where('id', '\d+');

Route::get('deactivate', function()
Expand Down Expand Up @@ -199,15 +210,10 @@
Route::get('/', function()
{
$user = Sentry::getUser();
$persistence = Sentry::getPersistence();
$activationCode = '';

if ( ! $user->isActivated())
{
$activationCode = Activation::exists($user);
}
$persistence = Sentry::getPersistence();

return View::make('sentry.account.home', compact('user', 'persistence', 'activationCode'));
return View::make('sentry.account.home', compact('user', 'persistence'));
});

Route::get('kill/{code}', function($code)
Expand Down Expand Up @@ -252,7 +258,7 @@

Session::reflash();

$user = Sentry::authenticate(compact('email', 'password'));
$user = Sentry::forceAuthenticateAndRemember(compact('email', 'password'));

if ( ! $user)
{
Expand Down Expand Up @@ -325,7 +331,7 @@
}

// We should expect another exception
Sentry::authenticate(compact('email', 'password'));
Sentry::forceAuthenticateAndRemember(compact('email', 'password'));

// We should never get here
return Redirect::to('login')
Expand Down Expand Up @@ -384,7 +390,7 @@

$user = SwipeIdentity::checkAnswer($user, Input::get('code'), function($user)
{
return Sentry::authenticate($user, (bool) Input::old('remember', false));
return Sentry::forceAuthenticateAndRemember($user, (bool) Input::old('remember', false));
});

if ( ! $user)
Expand Down
1 change: 1 addition & 0 deletions app/start/artisan.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
|
*/

Artisan::add(new DemoInstallCommand);
2 changes: 1 addition & 1 deletion app/views/sentry/account/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div class="col-md-6">
<h3>Activation</h3>

@if ($user->isActivated())
@if (Activation::completed($user))

<a class="btn btn-danger" href="{{ URL::to('deactivate') }}">Deactivate</a>

Expand Down
2 changes: 1 addition & 1 deletion app/views/sentry/emails/activate.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Activate your account by clicking <a href="{{ URL::to("activate/{$user->getUserId()}/{$activation->code}") }}">here</a>
Activate your account by clicking <a href="{{ URL::to("activate/{$user->getUserId()}/{$code}") }}">here</a>
2 changes: 1 addition & 1 deletion app/views/template.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@if ($user = Sentry::check())
<ul class="nav navbar-nav pull-right">
<li{{ Request::is('account') ? ' class="active"' : null }}><a href="{{ URL::to('account') }}">Account
@if ( ! $user->isActivated())
@if ( ! Activation::completed($user))
<span class="label label-danger">Inactive</span>
@endif
</a></li>
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"license": "MIT",
"require": {
"cartalyst/sentry": "dev-develop",
"doctrine/dbal": "2.5.*",
"laravel/framework": "4.1.*"
},
"autoload": {
Expand Down
Loading

0 comments on commit 9edfc69

Please sign in to comment.