Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Gaspar <[email protected]>
  • Loading branch information
brunogaspar committed Jan 17, 2014
1 parent ed993f1 commit abaaee2
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 55 deletions.
84 changes: 35 additions & 49 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
|
*/

DB::listen(function($sql, array $bindings)
{
foreach ($bindings as $binding)
{
$sql = preg_replace('/\?/', '"'.$binding.'"', $sql, 1);
}

// var_dump($sql);
});

Route::get('/', function()
{
Expand All @@ -46,9 +37,7 @@
return Redirect::back()->withInput()->withErrors($validator);
}

$user = Sentry::register(Input::get());

if ( ! $user)
if ( ! $user = Sentry::register(Input::get()))
{
return Redirect::to('register')->withInput()->withErrors('Failed to register.');
}
Expand Down Expand Up @@ -239,50 +228,47 @@

});

Route::group(['prefix' => 'swift'], function()
Route::group(['prefix' => 'swipe'], function()
{
Route::group(['prefix' => 'swipe'], function()
Route::get('register', function()
{
Route::get('register', function()
$login = Session::get('login');
$code = Session::get('code');

if ( ! $login or ! $code)
{
$login = Session::get('login');
$code = Session::get('code');
return Redirect::to('login')
->withErrors('Missing Swipe Identity swipe login or code.');
}

if ( ! $login or ! $code)
{
return Redirect::to('login')
->withErrors('Missing Swift Identity swipe login or code.');
}
Session::reflash();

Session::reflash();
return View::make('sentry.swipe.register', compact('login', 'code'));
});

return View::make('sentry.swift.swipe.register', compact('login', 'code'));
});
Route::get('registered', function()
{
$email = Input::old('email');
$password = Input::old('password');

Route::get('registered', function()
if ( ! $email or ! $password)
{
$email = Input::old('email');
$password = Input::old('password');
return Redirect::to('email')
->withErrors('Email or password have disappeared from the session.');
}

if ( ! $email or ! $password)
{
return Redirect::to('email')
->withErrors('Email or password have disappeared from the session.');
}

Session::reflash();
Session::reflash();

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

if ( ! $user)
{
return Redirect::to('login')
->withInput()
->withErrors('Login failed even after swipe was registered. Potential infinite loop.');
}
if ( ! $user)
{
return Redirect::to('login')
->withInput()
->withErrors('Login failed even after swipe was registered. Potential infinite loop.');
}

return Redirect::to('account');
});
return Redirect::to('account');
});

Route::group(['prefix' => 'sms'], function()
Expand All @@ -300,7 +286,7 @@

Session::reflash();

return View::make('sentry.swift.sms.register');
return View::make('sentry.swipe.sms.register');
});

Route::post('register', function()
Expand Down Expand Up @@ -337,12 +323,12 @@
->withErrors('User in session does not exist.');
}

$response = SwiftIdentity::saveNumber($user, Input::get('number'));
$response = SwipeIdentity::saveNumber($user, Input::get('number'));

if ( ! $response)
{
return Redirect::to('login')
->withErrors('Failed to send number to Swift Identity.');
->withErrors('Failed to send number to Swipe Identity.');
}

// We should expect another exception
Expand All @@ -366,7 +352,7 @@

Session::reflash();

return View::make('sentry.swift.sms.code');
return View::make('sentry.swipe.sms.code');
});

Route::post('code', function()
Expand Down Expand Up @@ -403,7 +389,7 @@
->withErrors('User in session does not exist.');
}

$user = SwiftIdentity::checkAnswer($user, Input::get('code'), function($user)
$user = SwipeIdentity::checkAnswer($user, Input::get('code'), function($user)
{
return Sentry::authenticate($user, (bool) Input::old('remember', false));
});
Expand Down
12 changes: 6 additions & 6 deletions app/start/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/swift',
app_path().'/swipe',

));

Expand Down Expand Up @@ -53,7 +53,7 @@
->withErrors($exception->getMessage());
});

App::error(function(Cartalyst\Sentry\Checkpoints\SwiftIdentityException $exception, $code)
App::error(function(Cartalyst\Sentry\Checkpoints\SwipeIdentityException $exception, $code)
{
$code = $exception->getCode();
$response = $exception->getResponse();
Expand All @@ -62,22 +62,22 @@
switch ($code)
{
case NEED_REGISTER_SMS:
return Redirect::to('swift/sms/register')
return Redirect::to('swipe/sms/register')
->withInput();

case NEED_REGISTER_SWIPE:
return Redirect::to('swift/swipe/register')
return Redirect::to('swipe/register')
->withInput()
->with('swipe_login', $user->getUserLogin())
->with('swipe_code', $response->getUserSwipeActivationCode());

case RC_SWIPE_REJECTED:
return Redirect::to('login')
->withErrors('Swift Identity authentication rejected by device.');
->withErrors('Swipe Identity authentication rejected by device.');
break;

case RC_SMS_DELIVERED:
return Redirect::to('swift/sms/code')
return Redirect::to('swipe/sms/code')
->withInput();

case RC_ERROR:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit abaaee2

Please sign in to comment.