|
|
|
<?php
|
|
|
|
use SocialNorm\Exceptions\ApplicationRejectedException;
|
|
|
|
use SocialNorm\Exceptions\InvalidAuthorizationCodeException;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Web Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Here is where you can register web routes for your application. These
|
|
|
|
| routes are loaded by the RouteServiceProvider within a group which
|
|
|
|
| contains the "web" middleware group. Now create something great!
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
Auth::routes();
|
|
|
|
|
|
|
|
|
|
|
|
Route::get('/about/terms', function () {
|
|
|
|
return view('terms');
|
|
|
|
});
|
|
|
|
|
|
|
|
Route::get('/about/privacy', function () {
|
|
|
|
return view('privacy');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Route::get('/', function () {
|
|
|
|
if (!Auth::guest()) {
|
|
|
|
return redirect('/home');
|
|
|
|
}
|
|
|
|
return view('welcome');
|
|
|
|
});
|
|
|
|
|
|
|
|
Route::get('/home', 'HomeController@index')->name('home');
|
|
|
|
|
|
|
|
// ----------------- SOCIAL LOGIN --------------------
|
|
|
|
|
|
|
|
Route::get('/auth/github/authorize', function() {
|
|
|
|
return SocialAuth::authorize('github');
|
|
|
|
})->name('oauth-github-authorize');
|
|
|
|
|
|
|
|
Route::get('/auth/github/callback', function() {
|
|
|
|
try {
|
|
|
|
SocialAuth::login('github');
|
|
|
|
} catch (ApplicationRejectedException $e) {
|
|
|
|
abort(401, $e->getMessage());
|
|
|
|
} catch (InvalidAuthorizationCodeException $e) {
|
|
|
|
abort(401, $e->getMessage());
|
|
|
|
}
|
|
|
|
return Redirect::intended();
|
|
|
|
})->name('oauth-github-callback');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Route::get('/auth/google/authorize', function() {
|
|
|
|
return SocialAuth::authorize('google');
|
|
|
|
})->name('oauth-google-authorize');
|
|
|
|
|
|
|
|
Route::get('/auth/google/callback', function() {
|
|
|
|
try {
|
|
|
|
SocialAuth::login('google');
|
|
|
|
} catch (ApplicationRejectedException $e) {
|
|
|
|
abort(401);
|
|
|
|
} catch (InvalidAuthorizationCodeException $e) {
|
|
|
|
abort(401);
|
|
|
|
}
|
|
|
|
return Redirect::intended();
|
|
|
|
})->name('oauth-google-callback');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Route::get('/auth/facebook/authorize', function() {
|
|
|
|
return SocialAuth::authorize('facebook');
|
|
|
|
})->name('oauth-facebook-authorize');
|
|
|
|
|
|
|
|
Route::get('/auth/facebook/callback', function() {
|
|
|
|
try {
|
|
|
|
SocialAuth::login('facebook');
|
|
|
|
} catch (ApplicationRejectedException $e) {
|
|
|
|
abort(401);
|
|
|
|
} catch (InvalidAuthorizationCodeException $e) {
|
|
|
|
abort(401);
|
|
|
|
}
|
|
|
|
return Redirect::intended();
|
|
|
|
})->name('oauth-facebook-callback');
|