datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
<?php
|
|
use SocialNorm\Exceptions\ApplicationRejectedException;
|
|
use SocialNorm\Exceptions\InvalidAuthorizationCodeException;
|
|
use SocialNorm\ProviderUser;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 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 --------------------
|
|
|
|
function _loginVia($method) {
|
|
try {
|
|
SocialAuth::login($method, function (\App\Models\User $user, ProviderUser $details) {
|
|
// update user name first time user logs in
|
|
if (!$user->exists) {
|
|
$user->name = $details->nickname ?: ($details->full_name ?: $details->email);
|
|
}
|
|
|
|
// set e-mail from provider data, only if user e-mail is empty
|
|
if ("$user->email" === "") {
|
|
$user->email = $details->email;
|
|
}
|
|
});
|
|
} catch (ApplicationRejectedException $e) {
|
|
abort(401, $e->getMessage());
|
|
} catch (InvalidAuthorizationCodeException $e) {
|
|
abort(401, $e->getMessage());
|
|
}
|
|
return Redirect::intended();
|
|
};
|
|
|
|
|
|
Route::get('/auth/github/authorize', function() {
|
|
return SocialAuth::authorize('github');
|
|
})->name('oauth-github-authorize');
|
|
|
|
Route::get('/auth/github/callback', function() {
|
|
return _loginVia('github');
|
|
})->name('oauth-github-callback');
|
|
|
|
|
|
Route::get('/auth/google/authorize', function() {
|
|
return SocialAuth::authorize('google');
|
|
})->name('oauth-google-authorize');
|
|
|
|
Route::get('/auth/google/callback', function() {
|
|
return _loginVia('google');
|
|
})->name('oauth-google-callback');
|
|
|
|
|
|
Route::get('/auth/facebook/authorize', function() {
|
|
return SocialAuth::authorize('facebook');
|
|
})->name('oauth-facebook-authorize');
|
|
|
|
Route::get('/auth/facebook/callback', function() {
|
|
return _loginVia('facebook');
|
|
})->name('oauth-facebook-callback');
|
|
|
|
|
|
Route::get('/auth/stack/authorize', function() {
|
|
return SocialAuth::authorize('stack');
|
|
})->name('oauth-stack-authorize');
|
|
|
|
Route::get('/auth/stack/callback', function() {
|
|
return _loginVia('stack');
|
|
})->name('oauth-stack-callback');
|
|
|