diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 191b2b6..958045b 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; +use Illuminate\Http\Request; +use Illuminate\Validation\ValidationException; class LoginController extends Controller { @@ -36,4 +38,19 @@ class LoginController extends Controller { $this->middleware('guest')->except('logout'); } + + public function username() + { + $login = request()->input('login'); + $field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'name'; + request()->merge([$field => $login]); + return $field; + } + + protected function sendFailedLoginResponse(Request $request) + { + throw ValidationException::withMessages([ + 'login' => [trans('auth.failed')], + ]); + } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/ProfileController.php similarity index 79% rename from app/Http/Controllers/UserController.php rename to app/Http/Controllers/ProfileController.php index 8b937e8..fdbd6a1 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/ProfileController.php @@ -10,7 +10,7 @@ use Illuminate\Http\Request; use Illuminate\Validation\Rule; use MightyPork\Utils\Str; -class UserController extends Controller +class ProfileController extends Controller { /** * Show the application dashboard. @@ -23,7 +23,7 @@ class UserController extends Controller ->with('revision:id,row_count') ->paginate(10); - return view('user.view')->with(compact('tables', 'user')); + return view('profile.view')->with(compact('tables', 'user')); } /** @@ -34,7 +34,7 @@ class UserController extends Controller */ public function edit() { - return view('user.edit')->with('user', \user()); + return view('profile.edit')->with('user', \user()); } /** @@ -92,6 +92,17 @@ class UserController extends Controller public function manageOauth() { - return view('user.logins', ['user' => user()]); + return view('profile.logins', ['user' => user()]); + } + + public function forgetSocialLogin($id) + { + $identity = user()->socialIdentities()->where('id', $id)->first(); + if (null === $identity) { + abort(404, "No such identity"); + } + + $identity->delete(); + return redirect(route('profile.manage-oauth')); } } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e4cec9c..e27860e 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -18,7 +18,7 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/home'); + return redirect('/'); } return $next($request); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 55bc903..2537cb7 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -20,7 +20,8 @@ class AppServiceProvider extends ServiceProvider } \Route::bind('user', function ($value) { - $u = User::where('name', $value)->first(); + // Hack to have the URL case insensitive (also needed a vendor patch for login) + $u = User::whereRaw('LOWER(name)=LOWER(?)', [$value])->first(); // it may also be the _id directly if (!$u && is_numeric($value)) $u = User::find((int)$value); if (!$u) abort(404); diff --git a/app/View/WidgetFactory.php b/app/View/WidgetFactory.php index c2e8c84..ffa104b 100644 --- a/app/View/WidgetFactory.php +++ b/app/View/WidgetFactory.php @@ -21,10 +21,11 @@ class WidgetFactory ""; } - public function par($text) + public function par($text, $extraClasses='') { - return "
". - "

fieldCols offset-md-$this->labelCols\">".e($text)."". + return + "

". + "

fieldCols offset-md-$this->labelCols mb-2 ".e($extraClasses)."\">".e($text)."". "

"; } diff --git a/database/migrations/2018_07_08_204449_create_oauth_identities_table.php b/database/migrations/2018_07_08_204449_create_oauth_identities_table.php index d84dd69..64f8ad9 100644 --- a/database/migrations/2018_07_08_204449_create_oauth_identities_table.php +++ b/database/migrations/2018_07_08_204449_create_oauth_identities_table.php @@ -20,6 +20,10 @@ class CreateOauthIdentitiesTable extends Migration $table->string('provider_user_id'); $table->string('provider'); $table->string('access_token'); + $table->string('nick_name'); + $table->string('full_name'); + $table->string('avatar', 500); + $table->string('email'); $table->foreign('user_id') ->references('id')->on('users') diff --git a/public/fonts/fa-dtbl-1-preview.html b/public/fonts/fa-dtbl-1-preview.html index 9faf934..93c87d3 100644 --- a/public/fonts/fa-dtbl-1-preview.html +++ b/public/fonts/fa-dtbl-1-preview.html @@ -161,7 +161,8 @@ [data-icon]:before { content: attr(data-icon); } [data-icon]:before, - .fa-at:before, + .fa-address-card-o:before, +.fa-at:before, .fa-bell:before, .fa-bell-o:before, .fa-calendar:before, @@ -219,50 +220,51 @@ font-smoothing: antialiased; } - .fa-at:before { content: "\f100"; } -.fa-bell:before { content: "\f101"; } -.fa-bell-o:before { content: "\f102"; } -.fa-calendar:before { content: "\f103"; } -.fa-check:before { content: "\f104"; } -.fa-clock-o:before { content: "\f105"; } -.fa-cloud-upload:before { content: "\f106"; } -.fa-code-fork:before { content: "\f107"; } -.fa-download:before { content: "\f108"; } -.fa-eye:before { content: "\f109"; } -.fa-eye-slash:before { content: "\f10a"; } -.fa-facebook-square:before { content: "\f10b"; } -.fa-filter:before { content: "\f10c"; } -.fa-flag:before { content: "\f10d"; } -.fa-floppy-o:before { content: "\f10e"; } -.fa-gavel:before { content: "\f10f"; } -.fa-github:before { content: "\f110"; } -.fa-globe:before { content: "\f111"; } -.fa-google:before { content: "\f112"; } -.fa-history:before { content: "\f113"; } -.fa-key-modern:before { content: "\f114"; } -.fa-link:before { content: "\f115"; } -.fa-pencil-square-o:before { content: "\f116"; } -.fa-question-circle:before { content: "\f117"; } -.fa-quote-left:before { content: "\f118"; } -.fa-reply:before { content: "\f119"; } -.fa-rss:before { content: "\f11a"; } -.fa-search:before { content: "\f11b"; } -.fa-share-alt:before { content: "\f11c"; } -.fa-sign-in:before { content: "\f11d"; } -.fa-sign-out:before { content: "\f11e"; } -.fa-sliders:before { content: "\f11f"; } -.fa-sort:before { content: "\f120"; } -.fa-sort-asc:before { content: "\f121"; } -.fa-sort-desc:before { content: "\f122"; } -.fa-star:before { content: "\f123"; } -.fa-star-o:before { content: "\f124"; } -.fa-table:before { content: "\f125"; } -.fa-times:before { content: "\f126"; } -.fa-trash:before { content: "\f127"; } -.fa-trash-o:before { content: "\f128"; } -.fa-user-circle-o:before { content: "\f129"; } -.fa-user-plus:before { content: "\f12a"; } -.fa-wrench:before { content: "\f12b"; } + .fa-address-card-o:before { content: "\f100"; } +.fa-at:before { content: "\f101"; } +.fa-bell:before { content: "\f102"; } +.fa-bell-o:before { content: "\f103"; } +.fa-calendar:before { content: "\f104"; } +.fa-check:before { content: "\f105"; } +.fa-clock-o:before { content: "\f106"; } +.fa-cloud-upload:before { content: "\f107"; } +.fa-code-fork:before { content: "\f108"; } +.fa-download:before { content: "\f109"; } +.fa-eye:before { content: "\f10a"; } +.fa-eye-slash:before { content: "\f10b"; } +.fa-facebook-square:before { content: "\f10c"; } +.fa-filter:before { content: "\f10d"; } +.fa-flag:before { content: "\f10e"; } +.fa-floppy-o:before { content: "\f10f"; } +.fa-gavel:before { content: "\f110"; } +.fa-github:before { content: "\f111"; } +.fa-globe:before { content: "\f112"; } +.fa-google:before { content: "\f113"; } +.fa-history:before { content: "\f114"; } +.fa-key-modern:before { content: "\f115"; } +.fa-link:before { content: "\f116"; } +.fa-pencil-square-o:before { content: "\f117"; } +.fa-question-circle:before { content: "\f118"; } +.fa-quote-left:before { content: "\f119"; } +.fa-reply:before { content: "\f11a"; } +.fa-rss:before { content: "\f11b"; } +.fa-search:before { content: "\f11c"; } +.fa-share-alt:before { content: "\f11d"; } +.fa-sign-in:before { content: "\f11e"; } +.fa-sign-out:before { content: "\f11f"; } +.fa-sliders:before { content: "\f120"; } +.fa-sort:before { content: "\f121"; } +.fa-sort-asc:before { content: "\f122"; } +.fa-sort-desc:before { content: "\f123"; } +.fa-star:before { content: "\f124"; } +.fa-star-o:before { content: "\f125"; } +.fa-table:before { content: "\f126"; } +.fa-times:before { content: "\f127"; } +.fa-trash:before { content: "\f128"; } +.fa-trash-o:before { content: "\f129"; } +.fa-user-circle-o:before { content: "\f12a"; } +.fa-user-plus:before { content: "\f12b"; } +.fa-wrench:before { content: "\f12c"; } @@ -278,11 +280,25 @@
-

fa-dtbl-1 contains 44 glyphs:

+

fa-dtbl-1 contains 45 glyphs:

Toggle Preview Characters
+
+
+ PpPpPpPpPpPpPpPpPpPp +
+
+ 12141618212436486072 +
+
+ + + +
+
+
PpPpPpPpPpPpPpPpPpPp @@ -292,7 +308,7 @@
- +
@@ -305,7 +321,7 @@
- +
@@ -318,7 +334,7 @@
- +
@@ -331,7 +347,7 @@
- +
@@ -344,7 +360,7 @@
- +
@@ -357,7 +373,7 @@
- +
@@ -370,7 +386,7 @@
- +
@@ -383,7 +399,7 @@
- +
@@ -396,7 +412,7 @@
- +
@@ -409,7 +425,7 @@
- +
@@ -422,7 +438,7 @@
- +
@@ -435,7 +451,7 @@
- +
@@ -448,7 +464,7 @@
- +
@@ -461,7 +477,7 @@
- +
@@ -475,7 +491,7 @@
- +
@@ -489,7 +505,7 @@
- +
@@ -502,7 +518,7 @@
- +
@@ -515,7 +531,7 @@
- +
@@ -528,7 +544,7 @@
- +
@@ -541,7 +557,7 @@
- +
@@ -554,7 +570,7 @@
- +
@@ -567,7 +583,7 @@
- +
@@ -581,7 +597,7 @@
- +
@@ -594,7 +610,7 @@
- +
@@ -607,7 +623,7 @@
- +
@@ -620,7 +636,7 @@
- +
@@ -633,7 +649,7 @@
- +
@@ -646,7 +662,7 @@
- +
@@ -659,7 +675,7 @@
- +
@@ -672,7 +688,7 @@
- +
@@ -685,7 +701,7 @@
- +
@@ -698,7 +714,7 @@
- +
@@ -711,7 +727,7 @@
- +
@@ -724,7 +740,7 @@
- +
@@ -737,7 +753,7 @@
- +
@@ -750,7 +766,7 @@
- +
@@ -763,7 +779,7 @@
- +
@@ -776,7 +792,7 @@
- +
@@ -790,7 +806,7 @@
- +
@@ -803,7 +819,7 @@
- +
@@ -816,7 +832,7 @@
- +
@@ -829,7 +845,7 @@
- +
@@ -842,7 +858,7 @@
- +
@@ -855,7 +871,7 @@
- +
diff --git a/public/fonts/fa-dtbl-1.css b/public/fonts/fa-dtbl-1.css index 25c5282..ec428cb 100644 --- a/public/fonts/fa-dtbl-1.css +++ b/public/fonts/fa-dtbl-1.css @@ -38,47 +38,48 @@ font-smoothing: antialiased; } -.fa-at::before { content: "\f100"; } -.fa-bell::before { content: "\f101"; } -.fa-bell-o::before { content: "\f102"; } -.fa-calendar::before { content: "\f103"; } -.fa-check::before { content: "\f104"; } -.fa-clock-o::before { content: "\f105"; } -.fa-cloud-upload::before { content: "\f106"; } -.fa-code-fork::before { content: "\f107"; } -.fa-download::before { content: "\f108"; } -.fa-eye::before { content: "\f109"; } -.fa-eye-slash::before { content: "\f10a"; } -.fa-facebook-square::before { content: "\f10b"; } -.fa-filter::before { content: "\f10c"; } -.fa-flag::before { content: "\f10d"; } -.fa-floppy-o::before, .fa-save::before { content: "\f10e"; } -.fa-gavel::before, .fa-legal::before { content: "\f10f"; } -.fa-github::before { content: "\f110"; } -.fa-globe::before { content: "\f111"; } -.fa-google::before { content: "\f112"; } -.fa-history::before { content: "\f113"; } -.fa-key-modern::before { content: "\f114"; } -.fa-link::before { content: "\f115"; } -.fa-pencil-square-o::before, .fa-edit::before { content: "\f116"; } -.fa-question-circle::before { content: "\f117"; } -.fa-quote-left::before { content: "\f118"; } -.fa-reply::before { content: "\f119"; } -.fa-rss::before { content: "\f11a"; } -.fa-search::before { content: "\f11b"; } -.fa-share-alt::before { content: "\f11c"; } -.fa-sign-in::before { content: "\f11d"; } -.fa-sign-out::before { content: "\f11e"; } -.fa-sliders::before { content: "\f11f"; } -.fa-sort::before { content: "\f120"; } -.fa-sort-asc::before { content: "\f121"; } -.fa-sort-desc::before { content: "\f122"; } -.fa-star::before { content: "\f123"; } -.fa-star-o::before { content: "\f124"; } -.fa-table::before { content: "\f125"; } -.fa-times::before, .fa-close::before { content: "\f126"; } -.fa-trash::before { content: "\f127"; } -.fa-trash-o::before { content: "\f128"; } -.fa-user-circle-o::before { content: "\f129"; } -.fa-user-plus::before { content: "\f12a"; } -.fa-wrench::before { content: "\f12b"; } +.fa-address-card-o::before, .fa-vcard-o::before { content: "\f100"; } +.fa-at::before { content: "\f101"; } +.fa-bell::before { content: "\f102"; } +.fa-bell-o::before { content: "\f103"; } +.fa-calendar::before { content: "\f104"; } +.fa-check::before { content: "\f105"; } +.fa-clock-o::before { content: "\f106"; } +.fa-cloud-upload::before { content: "\f107"; } +.fa-code-fork::before { content: "\f108"; } +.fa-download::before { content: "\f109"; } +.fa-eye::before { content: "\f10a"; } +.fa-eye-slash::before { content: "\f10b"; } +.fa-facebook-square::before { content: "\f10c"; } +.fa-filter::before { content: "\f10d"; } +.fa-flag::before { content: "\f10e"; } +.fa-floppy-o::before, .fa-save::before { content: "\f10f"; } +.fa-gavel::before, .fa-legal::before { content: "\f110"; } +.fa-github::before { content: "\f111"; } +.fa-globe::before { content: "\f112"; } +.fa-google::before { content: "\f113"; } +.fa-history::before { content: "\f114"; } +.fa-key-modern::before { content: "\f115"; } +.fa-link::before { content: "\f116"; } +.fa-pencil-square-o::before, .fa-edit::before { content: "\f117"; } +.fa-question-circle::before { content: "\f118"; } +.fa-quote-left::before { content: "\f119"; } +.fa-reply::before { content: "\f11a"; } +.fa-rss::before { content: "\f11b"; } +.fa-search::before { content: "\f11c"; } +.fa-share-alt::before { content: "\f11d"; } +.fa-sign-in::before { content: "\f11e"; } +.fa-sign-out::before { content: "\f11f"; } +.fa-sliders::before { content: "\f120"; } +.fa-sort::before { content: "\f121"; } +.fa-sort-asc::before { content: "\f122"; } +.fa-sort-desc::before { content: "\f123"; } +.fa-star::before { content: "\f124"; } +.fa-star-o::before { content: "\f125"; } +.fa-table::before { content: "\f126"; } +.fa-times::before, .fa-close::before { content: "\f127"; } +.fa-trash::before { content: "\f128"; } +.fa-trash-o::before { content: "\f129"; } +.fa-user-circle-o::before { content: "\f12a"; } +.fa-user-plus::before { content: "\f12b"; } +.fa-wrench::before { content: "\f12c"; } diff --git a/public/fonts/fa-dtbl-1.eot b/public/fonts/fa-dtbl-1.eot index c8b5a09..3fc4d1f 100644 Binary files a/public/fonts/fa-dtbl-1.eot and b/public/fonts/fa-dtbl-1.eot differ diff --git a/public/fonts/fa-dtbl-1.svg b/public/fonts/fa-dtbl-1.svg index 2a2f089..5bf0402 100644 --- a/public/fonts/fa-dtbl-1.svg +++ b/public/fonts/fa-dtbl-1.svg @@ -1,11 +1,11 @@ -Created by FontForge 20170805 at Sun Jul 22 23:07:59 2018 +Created by FontForge 20170805 at Wed Jul 25 20:38:52 2018 By ondra The Fork Awesome font is licensed under the SIL OFL 1.1 (http://scripts.sil.org/OFL). Fork Awesome is a fork based of off Font Awesome 4.7.0 by Dave Gandy. More info on licenses at https://forkawesome.github.io @@ -22,165 +22,170 @@ The Fork Awesome font is licensed under the SIL OFL 1.1 (http://scripts.sil.org/ bbox="-0.0376684 -256 2048 1536.01" underline-thickness="89.6" underline-position="-179.2" - unicode-range="U+0020-F12B" + unicode-range="U+0020-F12C" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/fonts/fa-dtbl-1.ttf b/public/fonts/fa-dtbl-1.ttf index 1e110b4..d669212 100644 Binary files a/public/fonts/fa-dtbl-1.ttf and b/public/fonts/fa-dtbl-1.ttf differ diff --git a/public/fonts/fa-dtbl-1.woff2 b/public/fonts/fa-dtbl-1.woff2 index 30263db..cd4d79b 100644 Binary files a/public/fonts/fa-dtbl-1.woff2 and b/public/fonts/fa-dtbl-1.woff2 differ diff --git a/resources/assets/sass/_fa-utils.scss b/resources/assets/sass/_fa-utils.scss index 91cd75c..fe09203 100644 --- a/resources/assets/sass/_fa-utils.scss +++ b/resources/assets/sass/_fa-utils.scss @@ -11,3 +11,7 @@ .fa-large { font-size: 1.6em; } + +.fa-huge { + font-size: 2em; +} diff --git a/resources/assets/sass/_helpers.scss b/resources/assets/sass/_helpers.scss index 8ddad0c..fee6245 100644 --- a/resources/assets/sass/_helpers.scss +++ b/resources/assets/sass/_helpers.scss @@ -18,3 +18,11 @@ display: none; } } + +.border-dashed { + border-style: dashed !important; +} + +.border-dotted { + border-style: dotted !important; +} diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index e101dd4..bbd021f 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -13,7 +13,7 @@ @php(Widget::setLayout(4, 6)) - {!! Widget::email('email', 'E-Mail Address')->required()->autofocus() !!} + {!! Widget::text('login', 'Username or E-Mail')->required()->autofocus() !!} {!! Widget::password('password', 'Password')->required() !!} {!! Widget::checkbox('remember', 'Remember Me')->checked(false) !!} diff --git a/resources/views/form/checkbox.blade.php b/resources/views/form/checkbox.blade.php index d59a72d..b5489b8 100644 --- a/resources/views/form/checkbox.blade.php +++ b/resources/views/form/checkbox.blade.php @@ -7,7 +7,7 @@
value?'checked':''}} + {{\MightyPork\Utils\Utils::parseBool($w->value)?'checked':''}} name="{{ $w->name }}">
@@ -84,7 +84,7 @@ @endif - @include('user._table-list') + @include('profile._table-list') diff --git a/resources/views/user/edit.blade.php b/resources/views/user/edit.blade.php deleted file mode 100644 index 2d2cdc4..0000000 --- a/resources/views/user/edit.blade.php +++ /dev/null @@ -1,49 +0,0 @@ -{{-- Profile edit form --}} - -@extends('layouts.app') - -@section('content') -
- @csrf - -
- @php(Widget::setLayout(3, 7)) - - {!! Widget::header(1, 'Settings') !!} - - {!! Widget::text('title', 'Display Name')->value($user->title)->required()->autofocus() - ->help('Shown on your profile page, tables, comments, etc.') !!} - - {!! Widget::text('name', 'Username')->value($user->name)->required() - ->prepend('@') - ->help('Part of your vanity URL. Caution: changing this will alter URLs of your tables.') !!} - - {!! Widget::textarea('bio', 'About Me')->value($user->bio)->height('8em') - ->help('This is shown in your profile box') !!} - - {!! Widget::text('website', 'Website')->value($user->website)->prepend('') - ->help('Custom clickable link shown on your profile page.') !!} - - {!! Widget::email('email', 'E-Mail Address')->value($user->email)->required() - ->help('Used to login and for password resets. - This field is protected; a change will be applied only after you confirm - the new e-mail address via a confirmation link we\'ll send you to it.') !!} - - {!! Widget::header(3, 'Password Change') !!} - {!! Widget::par('Leave empty to keep your current password (if any).') !!} - - {!! Widget::password('new_password', 'New Password') !!} - - {!! Widget::password('new_password_confirmation', 'Confirm New Password') !!} - -
-
- -
-
-
-
-@endsection diff --git a/resources/views/user/logins.blade.php b/resources/views/user/logins.blade.php deleted file mode 100644 index c6a0cb9..0000000 --- a/resources/views/user/logins.blade.php +++ /dev/null @@ -1,15 +0,0 @@ -{{-- Profile edit form --}} - -@extends('layouts.app') - -@section('content') -
-
- @php(Widget::setLayout(3, 7)) - - {!! Widget::header(1, 'Logins') !!} - -

TODO social logins, add email & change pw form here

-
-
-@endsection diff --git a/routes/login.php b/routes/login.php index 67934e7..8df2c12 100644 --- a/routes/login.php +++ b/routes/login.php @@ -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'); diff --git a/routes/web.php b/routes/web.php index 05d6a73..6eba96a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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'); diff --git a/sideload/adamwathan/eloquent-oauth/src/Authenticator.php b/sideload/adamwathan/eloquent-oauth/src/Authenticator.php index 3b04afd..8e5cfe6 100644 --- a/sideload/adamwathan/eloquent-oauth/src/Authenticator.php +++ b/sideload/adamwathan/eloquent-oauth/src/Authenticator.php @@ -93,6 +93,10 @@ class Authenticator $identity->provider = $providerAlias; $identity->provider_user_id = $details->id; $identity->access_token = $details->access_token; + $identity->nick_name = $details->nickname; + $identity->full_name = $details->full_name; + $identity->avatar = $details->avatar; + $identity->email = $details->email; $this->identities->store($identity); } } diff --git a/sideload/adamwathan/eloquent-oauth/src/OAuthIdentity.php b/sideload/adamwathan/eloquent-oauth/src/OAuthIdentity.php index f221e87..5b64562 100644 --- a/sideload/adamwathan/eloquent-oauth/src/OAuthIdentity.php +++ b/sideload/adamwathan/eloquent-oauth/src/OAuthIdentity.php @@ -8,9 +8,15 @@ use Illuminate\Database\Eloquent\Model; * @property $provider * @property $provider_user_id * @property $access_token + * @property $nick_name + * @property $full_name + * @property $avatar + * @property $email */ class OAuthIdentity extends Model { + protected $guarded = []; + protected static $configuredTable = 'oauth_identities'; public static function configureTable($table) diff --git a/sideload/socialnorm/facebook/src/FacebookProvider.php b/sideload/socialnorm/facebook/src/FacebookProvider.php index cab093e..9a5ccdb 100644 --- a/sideload/socialnorm/facebook/src/FacebookProvider.php +++ b/sideload/socialnorm/facebook/src/FacebookProvider.php @@ -21,6 +21,11 @@ class FacebookProvider extends OAuth2Provider 'timezone', ]; + protected function providerName() + { + return 'facebook'; + } + protected function getAuthorizeUrl() { return $this->authorizeUrl; diff --git a/sideload/socialnorm/github/src/GitHubProvider.php b/sideload/socialnorm/github/src/GitHubProvider.php index 4c1702c..5856ac7 100644 --- a/sideload/socialnorm/github/src/GitHubProvider.php +++ b/sideload/socialnorm/github/src/GitHubProvider.php @@ -24,6 +24,11 @@ class GitHubProvider extends OAuth2Provider ], ]; + protected function providerName() + { + return 'github'; + } + protected function getAuthorizeUrl() { return $this->authorizeUrl; diff --git a/sideload/socialnorm/google/src/GoogleProvider.php b/sideload/socialnorm/google/src/GoogleProvider.php index bad25c2..157ff51 100644 --- a/sideload/socialnorm/google/src/GoogleProvider.php +++ b/sideload/socialnorm/google/src/GoogleProvider.php @@ -21,6 +21,11 @@ class GoogleProvider extends OAuth2Provider 'user_details' => [], ]; + protected function providerName() + { + return 'google'; + } + protected function compileScopes() { return implode(' ', $this->scope); diff --git a/sideload/socialnorm/socialnorm/src/ProviderUser.php b/sideload/socialnorm/socialnorm/src/ProviderUser.php index 109a99f..302a29f 100644 --- a/sideload/socialnorm/socialnorm/src/ProviderUser.php +++ b/sideload/socialnorm/socialnorm/src/ProviderUser.php @@ -1,6 +1,7 @@ full_name = $this->fetch($attributes, 'full_name'); $this->avatar = $this->fetch($attributes, 'avatar'); $this->email = $this->fetch($attributes, 'email'); + $this->provider = $this->fetch($attributes, 'provider'); $this->raw = $raw; } diff --git a/sideload/socialnorm/socialnorm/src/Providers/OAuth2Provider.php b/sideload/socialnorm/socialnorm/src/Providers/OAuth2Provider.php index 306a42e..0944dd6 100644 --- a/sideload/socialnorm/socialnorm/src/Providers/OAuth2Provider.php +++ b/sideload/socialnorm/socialnorm/src/Providers/OAuth2Provider.php @@ -44,6 +44,8 @@ abstract class OAuth2Provider implements Provider return $this->redirectUri; } + protected abstract function providerName(); + public function authorizeUrl(string $state) : string { $url = $this->getAuthorizeUrl(); @@ -71,6 +73,7 @@ abstract class OAuth2Provider implements Provider $this->accessToken = $this->requestAccessToken(); $this->providerUserData = $this->requestUserData(); return new ProviderUser([ + 'provider' => $this->providerName(), 'access_token' => $this->accessToken, 'id' => $this->userId(), 'nickname' => $this->nickname(), diff --git a/sideload/socialnorm/stackoverflow/src/StackOverflowProvider.php b/sideload/socialnorm/stackoverflow/src/StackOverflowProvider.php index 823ad6e..823a7a9 100644 --- a/sideload/socialnorm/stackoverflow/src/StackOverflowProvider.php +++ b/sideload/socialnorm/stackoverflow/src/StackOverflowProvider.php @@ -29,6 +29,11 @@ class StackOverflowProvider extends OAuth2Provider 'user_details' => [], ]; + protected function providerName() + { + return 'stack'; + } + public function __construct(array $config, HttpClient $httpClient, Request $request) { parent::__construct($config, $httpClient, $request); diff --git a/vendor_patches/20_ci_login.patch b/vendor_patches/20_ci_login.patch new file mode 100644 index 0000000..f3130d8 --- /dev/null +++ b/vendor_patches/20_ci_login.patch @@ -0,0 +1,11 @@ +--- vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.orig.php 2018-07-25 22:46:46.980782012 +0200 ++++ vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php 2018-07-25 22:48:47.490981175 +0200 +@@ -121,7 +121,7 @@ + if (is_array($value) || $value instanceof Arrayable) { + $query->whereIn($key, $value); + } else { +- $query->where($key, $value); ++ $query->whereRaw('LOWER(' . $key . ')=LOWER(?)', [$value]); + } + } +