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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
3 deletions
-
app/Providers/AppServiceProvider.php
|
|
@ -72,7 +72,8 @@ class AppServiceProvider extends ServiceProvider |
|
|
|
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); |
|
|
|
} |
|
|
|
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']]; |
|
|
|
|
|
|
|
if (\Auth::attempt($credentials, true)) { |
|
|
@ -84,10 +85,12 @@ class AppServiceProvider extends ServiceProvider |
|
|
|
} |
|
|
|
elseif(isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) { |
|
|
|
$user = User::where('username', $_SERVER['REMOTE_USER'])->first(); |
|
|
|
if ($user) { |
|
|
|
\Auth::login($user, true); |
|
|
|
session(['current_user' => $user]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$alt_bg = ''; |
|
|
|