Browse Source

Merge pull request #412 from vincentbitter/remote_user-login

Fix auto-login using REMOTE_USER variable
pull/438/head
KodeStar 5 years ago
committed by GitHub
parent
commit
e7a6ac5a75
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/Providers/AppServiceProvider.php

5
app/Providers/AppServiceProvider.php

@ -72,7 +72,8 @@ class AppServiceProvider extends ServiceProvider
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
} }
if(!\Auth::check()) { if(!\Auth::check()) {
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])
&& !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
$credentials = ['username' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']]; $credentials = ['username' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']];
if (\Auth::attempt($credentials, true)) { if (\Auth::attempt($credentials, true)) {
@ -84,10 +85,12 @@ class AppServiceProvider extends ServiceProvider
} }
elseif(isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) { elseif(isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) {
$user = User::where('username', $_SERVER['REMOTE_USER'])->first(); $user = User::where('username', $_SERVER['REMOTE_USER'])->first();
if ($user) {
\Auth::login($user, true); \Auth::login($user, true);
session(['current_user' => $user]); session(['current_user' => $user]);
} }
} }
}
$alt_bg = ''; $alt_bg = '';

Loading…
Cancel
Save