add basic auth support and put username in switch user section
This commit is contained in:
parent
4c8c5fa27f
commit
cb21b0f8f1
|
@ -75,6 +75,20 @@ class AppServiceProvider extends ServiceProvider
|
||||||
if(env('APP_URL') != 'http://localhost') {
|
if(env('APP_URL') != 'http://localhost') {
|
||||||
\URL::forceRootUrl(env('APP_URL'));
|
\URL::forceRootUrl(env('APP_URL'));
|
||||||
}
|
}
|
||||||
|
if(isset($_SERVER['HTTP_AUTHORIZATION']) && !empty($_SERVER['HTTP_AUTHORIZATION'])) {
|
||||||
|
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
|
||||||
|
explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
|
||||||
|
}
|
||||||
|
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||||
|
$credentials = ['username' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']];
|
||||||
|
|
||||||
|
if (\Auth::attempt($credentials)) {
|
||||||
|
// Authentication passed...
|
||||||
|
$user = \Auth::user();
|
||||||
|
session(['current_user' => $user]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
@else
|
@else
|
||||||
<img class="user-img" src="{{ asset('/img/heimdall-icon-small.png') }}" />
|
<img class="user-img" src="{{ asset('/img/heimdall-icon-small.png') }}" />
|
||||||
@endif
|
@endif
|
||||||
{{ $current_user->name }}
|
{{ $current_user->username }}
|
||||||
<a class="btn" href="{{ route('user.select') }}">Switch User</a>
|
<a class="btn" href="{{ route('user.select') }}">Switch User</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
Loading…
Reference in a new issue