Skip to content
This repository has been archived by the owner on Jan 18, 2018. It is now read-only.

Commit

Permalink
Released 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed May 24, 2014
1 parent c9b558e commit 147d607
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ CHANGE LOG
* Upgrade to Laravel 4.2


## V0.2.1 Alpha (24/05/2014)

* Added the "auth" helper to the blade compiler


## V0.2 Alpha (21/04/2014)

* PHP 5.6 and HHVM compatibility
Expand Down
24 changes: 24 additions & 0 deletions src/CredentialsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,37 @@ public function boot()
{
$this->package('graham-campbell/credentials', 'graham-campbell/credentials', __DIR__);

$this->setupBlade();

$this->setupViewer();

include __DIR__.'/routes.php';
include __DIR__.'/filters.php';
include __DIR__.'/listeners.php';
}

/**
* Setup the blade compiler class.
*
* @return void
*/
protected function setupBlade()
{
$blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler();

$blade->extend(function ($value, $compiler) {
$pattern = $compiler->createMatcher('auth');
$replace = '$1<?php if (\GrahamCampbell\Credentials\Facades\Credentials::check() && \GrahamCampbell\Credentials\Facades\Credentials::hasAccess$2): ?>';
return preg_replace($pattern, $replace, $value);
});

$blade->extend(function ($value, $compiler) {
$pattern = $compiler->createPlainMatcher('endauth');
$replace = '$1<?php endif; ?>$2';
return preg_replace($pattern, $replace, $value);
});
}

/**
* Setup the viewer class.
*
Expand Down
8 changes: 4 additions & 4 deletions src/views/users/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
<div class="pull-right">
&nbsp;<a class="btn btn-success" href="{{ URL::route('users.show', array('users' => $user->id)) }}"><i class="fa fa-file-text"></i> Show User</a>
&nbsp;<a class="btn btn-warning" href="#suspend_user" data-toggle="modal" data-target="#suspend_user"><i class="fa fa-ban"></i> Suspend User</a>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
&nbsp;<a class="btn btn-inverse" href="#reset_user" data-toggle="modal" data-target="#reset_user"><i class="fa fa-lock"></i> Reset Password</a>
&nbsp;<a class="btn btn-danger" href="#delete_user" data-toggle="modal" data-target="#delete_user"><i class="fa fa-times"></i> Delete</a>
@endif
@endauth
</div>
</div>
</div>
Expand All @@ -53,10 +53,10 @@

@section('bottom')
@include('graham-campbell/credentials::users.suspend')
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
@include('graham-campbell/credentials::users.reset')
@include('graham-campbell/credentials::users.delete')
@endif
@endauth
@stop

@section('css')
Expand Down
16 changes: 8 additions & 8 deletions src/views/users/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<div class="col-xs-8">
<p class="lead">Here is a list of all the current users:</p>
</div>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
<div class="col-xs-4">
<div class="pull-right">
<a class="btn btn-primary" href="{{ URL::route('users.create') }}"><i class="fa fa-user"></i> New User</a>
</div>
</div>
@endif
@endauth
</div>
<hr>
<div class="well">
Expand All @@ -38,14 +38,14 @@
<td>{{ $user->email }}</td>
<td>
&nbsp;<a class="btn btn-success" href="{{ URL::route('users.show', array('users' => $user->id)) }}"><i class="fa fa-file-text"></i> Show</a>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
&nbsp;<a class="btn btn-info" href="{{ URL::route('users.edit', array('users' => $user->id)) }}"><i class="fa fa-pencil-square-o"></i> Edit</a>
@endif
@endauth
&nbsp;<a class="btn btn-warning" href="#suspend_user_{{ $user->id }}" data-toggle="modal" data-target="#suspend_user_{{ $user->id }}"><i class="fa fa-ban"></i> Suspend</a>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
&nbsp;<a class="btn btn-inverse" href="#reset_user_{{ $user->id }}" data-toggle="modal" data-target="#reset_user_{{ $user->id }}"><i class="fa fa-lock"></i> Reset Password</a>
&nbsp;<a class="btn btn-danger" href="#delete_user_{{ $user->id }}" data-toggle="modal" data-target="#delete_user_{{ $user->id }}"><i class="fa fa-times"></i> Delete</a>
@endif
@endauth
</td>
</tr>
@endforeach
Expand All @@ -57,8 +57,8 @@

@section('bottom')
@include('graham-campbell/credentials::users.suspends')
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
@include('graham-campbell/credentials::users.resets')
@include('graham-campbell/credentials::users.deletes')
@endif
@endauth
@stop
16 changes: 8 additions & 8 deletions src/views/users/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
</div>
<div class="col-xs-6">
<div class="pull-right">
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
&nbsp;<a class="btn btn-info" href="{{ URL::route('users.edit', array('users' => $user->id)) }}"><i class="fa fa-pencil-square-o"></i> Edit User</a>
@endif
@endauth
&nbsp;<a class="btn btn-warning" href="#suspend_user" data-toggle="modal" data-target="#suspend_user"><i class="fa fa-ban"></i> Suspend User</a>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
&nbsp;<a class="btn btn-inverse" href="#reset_user" data-toggle="modal" data-target="#reset_user"><i class="fa fa-lock"></i> Reset Password</a>
&nbsp;<a class="btn btn-danger" href="#delete_user" data-toggle="modal" data-target="#delete_user"><i class="fa fa-times"></i> Delete</a>
@endif
@endauth
</div>
</div>
</div>
Expand Down Expand Up @@ -74,22 +74,22 @@
</div>
</div>
</div>
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
<hr>
<h3>User Object</h3>
<div>
<pre>{{ var_dump($user) }}</pre>
</div>
@endif
@endauth
@stop

@section('bottom')
@include('graham-campbell/credentials::users.suspend')
@if (Credentials::check() && Credentials::hasAccess('admin'))
@auth('admin')
@if (Config::get('graham-campbell/credentials::activation'))
@include('graham-campbell/credentials::users.resend')
@endif
@include('graham-campbell/credentials::users.reset')
@include('graham-campbell/credentials::users.delete')
@endif
@endauth
@stop

0 comments on commit 147d607

Please sign in to comment.