implemented social identities management page + pw editing page. probably need to fix backend

This commit is contained in:
2018-07-25 23:07:11 +02:00
parent 57911377ef
commit 2e075799f2
35 changed files with 541 additions and 301 deletions
+24 -3
View File
@@ -11,8 +11,24 @@ Auth::routes();
// ----------------- SOCIAL LOGIN --------------------
function _loginVia($method) {
$wasLoggedIn = !guest();
try {
SocialAuth::login($method, function (User $user, ProviderUser $details) {
SocialAuth::login($method, function (User $user, ProviderUser $details) use($wasLoggedIn) {
if ($user->exists && !$wasLoggedIn) {
// check if this identity already existed
if (! $user->socialIdentities()
->where('provider', $details->provider)
->where('provider_user_id', $details->id)
->exists()) {
Auth::logout();
abort(403,
"Account with this e-mail already exists. Add the identity
to the account manually after logging in through an existing
authentication method.");
}
}
// update user name first time user logs in
if (!$user->exists) {
$basename = $details->nickname ?: ($details->full_name ?: $details->email);
@@ -28,7 +44,6 @@ function _loginVia($method) {
if ("$user->email" === "") {
$user->email = $details->email;
}
$user->confirmed = true; // mark as confirmed, we trust the provider
});
} catch (ApplicationRejectedException $e) {
@@ -36,7 +51,11 @@ function _loginVia($method) {
} catch (InvalidAuthorizationCodeException $e) {
abort(401, $e->getMessage());
}
return Redirect::intended();
if ($wasLoggedIn)
return redirect(route('profile.manage-oauth'));
else
return Redirect::intended();
};
@@ -66,6 +85,8 @@ Route::get('/auth/facebook/callback', function() {
return _loginVia('facebook');
})->name('oauth-facebook-callback');
Route::get('/auth/forget/{id}', 'ProfileController@forgetSocialLogin')->name('forget-identity');
/*
Route::get('/auth/stack/authorize', function() {
return SocialAuth::authorize('stack');
+6 -6
View File
@@ -13,7 +13,7 @@ Route::get('/about/privacy', function () {
Route::get('/', function () {
if (!Auth::guest()) {
return redirect(route('user.view', Auth::user()->name));
return redirect(route('profile.view', Auth::user()->name));
}
return view('welcome');
});
@@ -28,15 +28,15 @@ Route::group(['middleware' => 'auth'], function () {
});
Route::group([
'prefix' => 'user',
'prefix' => 'profile',
], function () {
Route::get('edit', 'UserController@edit')->name('user.edit');
Route::post('edit', 'UserController@store')->name('user.store');
Route::get('edit', 'ProfileController@edit')->name('profile.edit');
Route::post('edit', 'ProfileController@store')->name('profile.store');
Route::post('create', 'TableController@storeNew')->name('table.storeNew');
Route::get('logins', 'UserController@manageOauth')->name('user.manage-oauth');
Route::get('logins', 'ProfileController@manageOauth')->name('profile.manage-oauth');
});
});
// Table resource - located at the end to work as a fallback
Route::get('@{user}', 'UserController@view')->name('user.view');
Route::get('@{user}', 'ProfileController@view')->name('profile.view');
Route::get('@{user}/{table}', 'TableController@view')->name('table.view');