diff --git a/app/routes.php b/app/routes.php index 19ef7779..32e5ee8c 100644 --- a/app/routes.php +++ b/app/routes.php @@ -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() { @@ -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.'); } @@ -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() @@ -300,7 +286,7 @@ Session::reflash(); - return View::make('sentry.swift.sms.register'); + return View::make('sentry.swipe.sms.register'); }); Route::post('register', function() @@ -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 @@ -366,7 +352,7 @@ Session::reflash(); - return View::make('sentry.swift.sms.code'); + return View::make('sentry.swipe.sms.code'); }); Route::post('code', function() @@ -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)); }); diff --git a/app/start/global.php b/app/start/global.php index 2643b30f..b3a670c3 100644 --- a/app/start/global.php +++ b/app/start/global.php @@ -17,7 +17,7 @@ app_path().'/controllers', app_path().'/models', app_path().'/database/seeds', - app_path().'/swift', + app_path().'/swipe', )); @@ -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(); @@ -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: diff --git a/app/swift/ApiBase.php b/app/swipe/ApiBase.php similarity index 100% rename from app/swift/ApiBase.php rename to app/swipe/ApiBase.php diff --git a/app/swift/Error.php b/app/swipe/Error.php similarity index 100% rename from app/swift/Error.php rename to app/swipe/Error.php diff --git a/app/swift/SpiBaseObject.php b/app/swipe/SpiBaseObject.php similarity index 100% rename from app/swift/SpiBaseObject.php rename to app/swipe/SpiBaseObject.php diff --git a/app/swift/SpiExpressApplication.php b/app/swipe/SpiExpressApplication.php similarity index 100% rename from app/swift/SpiExpressApplication.php rename to app/swipe/SpiExpressApplication.php diff --git a/app/swift/SpiExpressSecondFactor.php b/app/swipe/SpiExpressSecondFactor.php similarity index 100% rename from app/swift/SpiExpressSecondFactor.php rename to app/swipe/SpiExpressSecondFactor.php diff --git a/app/swift/SpiExpressUser.php b/app/swipe/SpiExpressUser.php similarity index 100% rename from app/swift/SpiExpressUser.php rename to app/swipe/SpiExpressUser.php diff --git a/app/swift/SwiftApiList.php b/app/swipe/SwiftApiList.php similarity index 100% rename from app/swift/SwiftApiList.php rename to app/swipe/SwiftApiList.php diff --git a/app/swift/SwiftApiNull.php b/app/swipe/SwiftApiNull.php similarity index 100% rename from app/swift/SwiftApiNull.php rename to app/swipe/SwiftApiNull.php diff --git a/app/swift/SwiftApiStringObject.php b/app/swipe/SwiftApiStringObject.php similarity index 100% rename from app/swift/SwiftApiStringObject.php rename to app/swipe/SwiftApiStringObject.php diff --git a/app/swift/SwiftIdentityExpressApi.php b/app/swipe/SwiftIdentityExpressApi.php similarity index 100% rename from app/swift/SwiftIdentityExpressApi.php rename to app/swipe/SwiftIdentityExpressApi.php diff --git a/app/views/sentry/swift/swipe/register.blade.php b/app/views/sentry/swipe/register.blade.php similarity index 100% rename from app/views/sentry/swift/swipe/register.blade.php rename to app/views/sentry/swipe/register.blade.php diff --git a/app/views/sentry/swift/sms/code.blade.php b/app/views/sentry/swipe/sms/code.blade.php similarity index 100% rename from app/views/sentry/swift/sms/code.blade.php rename to app/views/sentry/swipe/sms/code.blade.php diff --git a/app/views/sentry/swift/sms/register.blade.php b/app/views/sentry/swipe/sms/register.blade.php similarity index 100% rename from app/views/sentry/swift/sms/register.blade.php rename to app/views/sentry/swipe/sms/register.blade.php