Remove Auth calls from views

This commit is contained in:
Joseph Cohen 2015-01-28 00:51:28 -06:00
parent 5b618c0291
commit cce057c2d3
13 changed files with 46 additions and 24 deletions

View File

@ -56,7 +56,7 @@
</div>
</fieldset>
<input type="hidden" name="component[user_id]" value="{{ Auth::user()->id }}">
<input type="hidden" name="component[user_id]" value="{{ $loggedUser->id }}">
<input type="hidden" name="component[order]" value="0">
<div class="form-group">

View File

@ -56,7 +56,7 @@
</div>
</fieldset>
<input type="hidden" name="component[user_id]" value="{{ $component->agent_id || Auth::user()->id }}">
<input type="hidden" name="component[user_id]" value="{{ $component->agent_id || $loggedUser->id }}">
<input type="hidden" name="component[order]" value="{{ $component->order or 0 }}">
<div class="form-group">

View File

@ -88,7 +88,7 @@
</div>
</fieldset>
<input type="hidden" name="incident[user_id]" value="{{ Auth::user()->id }}">
<input type="hidden" name="incident[user_id]" value="{{ $loggedUser->id }}">
<div class="form-group">
<div class="btn-group">

View File

@ -77,7 +77,7 @@
</div>
</fieldset>
<input type="hidden" name="incident[user_id]" value="{{ Auth::user()->id }}">
<input type="hidden" name="incident[user_id]" value="{{ $loggedUser->id }}">
<input type="hidden" name="incident[id]" value={{$incident->id}}>
<div class="form-group">

View File

@ -25,13 +25,13 @@
</div>
<div class="form-group">
<label>{{ trans('forms.user.password') }}</label>
<input type="password" class="form-control" name="password" value="" {{ !Auth::user()->isAdmin ? "disabled": "" }}>
<input type="password" class="form-control" name="password" value="" {{ !$loggedUser->isAdmin ? "disabled": "" }}>
</div>
</fieldset>
<div class="form-group">
<button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button>
@if(Auth::user()->isAdmin)
@if($loggedUser->isAdmin)
<a class="btn btn-danger" href="/dashboard/user/{{ $user->id }}/api/regen">{{ trans('cachet.api.revoke') }}</a>
@endif
</div>

View File

@ -8,7 +8,7 @@
<span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('dashboard.team.team') }}
</span>
@if(Auth::user()->isAdmin)
@if($loggedUser->isAdmin)
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.team.add') }}">
{{ trans('dashboard.team.add.title') }}
</a>
@ -23,7 +23,7 @@
<div class="user-grid">
@foreach($teamMembers as $member)
<div class="user col-sm-3 col-xs-6">
<a href="@if(Auth::user()->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif">
<a href="@if($loggedUser->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif">
<img src="{{ $member->gravatar }}">
</a>
<div class="name">{{ $member->username }}</div>

View File

@ -17,11 +17,11 @@
<fieldset>
<div class="form-group">
<label>{{ trans('forms.user.username') }}</label>
<input type="text" class="form-control" name="username" value="{{ Auth::user()->username }}" required>
<input type="text" class="form-control" name="username" value="{{ $loggedUser->username }}" required>
</div>
<div class="form-group">
<label>{{ trans('forms.user.email') }}</label>
<input type="email" class="form-control" name="email" value="{{ Auth::user()->email }}" required>
<input type="email" class="form-control" name="email" value="{{ $loggedUser->email }}" required>
</div>
<div class="form-group">
<label>{{ trans('forms.user.password') }}</label>
@ -30,24 +30,24 @@
<hr>
<div class="form-group">
<label>{{ trans('forms.user.api-token') }}</label>
<input type="text" class="form-control" name="api_key" disabled value="{{ Auth::user()->api_key }}">
<input type="text" class="form-control" name="api_key" disabled value="{{ $loggedUser->api_key }}">
<span class="help-block">{{ trans('forms.user.api-token-help') }}</span>
</div>
<hr>
<div class="form-group">
<label class="checkbox-inline">
<input type="hidden" name="google2fa" value="0">
<input type='checkbox' name="google2fa" value="1" {{ Auth::user()->hasTwoFactor ? "checked" : "" }}>
<input type='checkbox' name="google2fa" value="1" {{ $loggedUser->hasTwoFactor ? "checked" : "" }}>
{{ trans('forms.setup.enable_google2fa') }}
</label>
</div>
@if(Auth::user()->hasTwoFactor)
@if($loggedUser->hasTwoFactor)
<div class="form-group">
<?php
$google2fa_url = PragmaRX\Google2FA\Vendor\Laravel\Facade::getQRCodeGoogleUrl(
'CachetHQ',
Auth::user()->email,
Auth::user()->google_2fa_secret
$loggedUser->email,
$loggedUser->google_2fa_secret
);
?>
<img src="{{ $google2fa_url }}" class="img-responsive">
@ -58,7 +58,7 @@
<div class="form-group">
<button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button>
<a href="/dashboard/user/{{ Auth::user()->id }}/api/regen" class="btn btn-warning">{{ trans('cachet.api.regenerate') }}</a>
<a href="/dashboard/user/{{ $loggedUser->id }}/api/regen" class="btn btn-warning">{{ trans('cachet.api.regenerate') }}</a>
</div>
</form>
</div>

View File

@ -1,4 +1,4 @@
@if(Auth::check())
@if($loggedUser)
<div class="sidebar">
<div class="sidebar-inner">
<div class="profile">
@ -6,13 +6,13 @@
<div class="col-xs-3">
<div class="avatar">
<a href="{{ url('dashboard/user') }}">
<img src="{{ Auth::user()->gravatar }}" alt="">
<img src="{{ $loggedUser->gravatar }}" alt="">
</a>
</div>
</div>
<div class="col-xs-9 username-wrapper">
<div class="profile pull-left">
<div class="username">{{ Auth::user()->username }}</div>
<div class="username">{{ $loggedUser->username }}</div>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@
<p>{{ trans('cachet.powered_by', ['app' => Setting::get('app_name')]) }}</p>
@endif
<p><a href="/rss"><i class="ion-social-rss"></i> {{ trans('cachet.rss-feed') }}</a>&nbsp;-&nbsp;<a href="/atom"><i class="ion-social-rss"></i> {{ trans('cachet.atom-feed') }}</a></p>
@if(Auth::check())
@if($loggedUser)
<p>
<a href="{{ route('dashboard') }}">{{ trans('dashboard.dashboard') }}</a> &ndash; <a href="{{ route('logout') }}">{{ trans('dashboard.logout') }}</a>
</p>

View File

@ -4,7 +4,7 @@ namespace CachetHQ\Cachet\Composers;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use Illuminate\Support\Facades\View;
use Illuminate\View\View;
class IndexComposer
{
@ -15,7 +15,7 @@ class IndexComposer
*
* @return void
*/
public function compose(\Illuminate\View\View $view)
public function compose(View $view)
{
// Default data
$withData = [

View File

@ -0,0 +1,21 @@
<?php
namespace CachetHQ\Cachet\Composers;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class LoggedUserComposer
{
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
*
* @return void
*/
public function compose(View $view)
{
$view->with('loggedUser', Auth::user());
}
}

View File

@ -5,7 +5,7 @@ namespace CachetHQ\Cachet\Composers;
use DateTime;
use DateTimeZone;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Illuminate\View\View;
class TimezoneLocaleComposer
{
@ -16,7 +16,7 @@ class TimezoneLocaleComposer
*
* @return void
*/
public function compose(\Illuminate\View\View $view)
public function compose(View $view)
{
$enabledLangs = Config::get('langs');

View File

@ -23,6 +23,7 @@ class ViewComposerServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
$this->app->view->composer([
'setup',