Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12945756
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/app/Helpers/.gitkeep b/app/Helpers/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/app/Helpers/Routing.php b/app/Helpers/Routing.php
new file mode 100644
index 0000000..a136198
--- /dev/null
+++ b/app/Helpers/Routing.php
@@ -0,0 +1,28 @@
+<?php
+
+use AuthGrove\Http\Controllers\Auth\AuthController;
+
+/*
+|--------------------------------------------------------------------------
+| Blade helper global functions
+|--------------------------------------------------------------------------
+|
+| This file register global helper functions to act as convenient aliases
+| for methods normally requiring a fully qualified class name with namespaces
+| to use in Blade template.
+|
+| e.g. {{ authurl('login') }} is a shorthand syntax for the longer construct
+[ {{ url(AuthGrove\Http\Controllers\Auth\AuthController::getRoute('login')) }}
+|
+*/
+
+/**
+ * Gets the full URL of a specified auth route.
+ *
+ * @param string $action The authentication action (e.g. login) [facultative]
+ * @return string The full URL (e.g. https://grove.domain.tld/auth/login)
+ */
+function authurl ($action = '') {
+ $route = AuthController::getRoute($action);
+ return url($route);
+}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 3309ce3..9866b1e 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -1,36 +1,26 @@
<?php namespace AuthGrove\Providers;
use Illuminate\Support\ServiceProvider;
-use AuthGrove\Http\Controllers\Auth\AuthController;
-
-use Blade;
-
class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot() {
- // Blade templates can invoke AuthController::getRoute as authurl()
- Blade::directive('authurl', function ($expression) {
- preg_match("@\('(.*)'\)@", $expression, $matches); // ('foo') → foo
- $action = $matches[1];
- return url(AuthController::getRoute($action));
- });
}
/**
* Register any application services.
*
* This service provider is a great spot to register your various container
* bindings with the application.
*
* @return void
*/
public function register() {
}
}
diff --git a/app/Providers/HelpersServiceProvider.php b/app/Providers/HelpersServiceProvider.php
index ade0387..d82ea02 100644
--- a/app/Providers/HelpersServiceProvider.php
+++ b/app/Providers/HelpersServiceProvider.php
@@ -1,26 +1,27 @@
<?php
namespace AuthGrove\Providers;
use Illuminate\Support\ServiceProvider;
class HelpersServiceProvider extends ServiceProvider {
/**
* Bootstraps the application services.
*
* @return void
*/
public function boot() {
//
}
/**
* Registers the application services.
*
* @return void
*/
public function register() {
+ require_once app_path() . '/Helpers/Routing.php';
}
}
diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php
index a39aafa..6f9351c 100644
--- a/resources/views/app.blade.php
+++ b/resources/views/app.blade.php
@@ -1,59 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@lang('app.title')</title>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" integrity="sha384-604wwakM23pEysLJAhja8Lm42IIwYrJ0dEAqzFsj9pJ/P5buiujjywArgPCi8eoz" crossorigin="anonymous" />
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<link href="{{ asset('/css/app.css') }}" rel="stylesheet">
<!-- Fonts -->
<link href="//fonts.googleapis.com/css?family=Roboto:400,300" rel="stylesheet" type="text/css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">@lang('panel.toggle-navigation')</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">@lang('app.title')</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ url('/') }}">@lang('panel.home')</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ Auth::user()->getName() }} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
- <li><a href="@authurl('logout')">@lang('panel.logout')</a></li>
+ <li><a href="{{ authurl('logout') }}">@lang('panel.logout')</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
@yield('content')
<!-- Scripts -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" integrity="sha384-CgeP3wqr9h5YanePjYLENwCTSSEz42NJkbFpAFgHWQz7u3Zk8D00752ScNpXqGjS" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js" integrity="sha384-Nud2SriDt2fZ+u85IBC48Yn9p+l4AGlapnX1EGA2KrnZjYJx8sxKnw/CIxc1wU1B" crossorigin="anonymous"></script>
</body>
</html>
diff --git a/resources/views/auth/fatal-error.blade.php b/resources/views/auth/fatal-error.blade.php
index 77ffc9c..0da5c79 100644
--- a/resources/views/auth/fatal-error.blade.php
+++ b/resources/views/auth/fatal-error.blade.php
@@ -1,12 +1,12 @@
@extends('auth.master')
@section('card-content')
<h1 class="title">@lang('app.title')</h1>
<p>@lang('auth.fatal-error')</p>
<p class="errors">
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
</p>
- <a href="@authurl('login')" class="action-link">@lang('login.goto-login')</a>
+ <a href="{{ authurl('login') }}" class="action-link">@lang('login.goto-login')</a>
@endsection
diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php
index 68890f6..9f0c513 100644
--- a/resources/views/auth/login.blade.php
+++ b/resources/views/auth/login.blade.php
@@ -1,33 +1,33 @@
@extends('auth.master')
@section('card-content')
<h1 class="title">@lang('app.title')</h1>
<img id="profile-img" class="profile-img-card" src="/images/profile-img-blank.png" alt="@lang('login.blankAvatarAlt')" />
- <form class="form-signin" role="form" method="POST" action="@authurl('login')">
+ <form class="form-signin" role="form" method="POST" action="{{ authurl('login') }}">
<div id="identity">
<span id="reauth-username" class="reauth-username"></span>
<input type="text" name="username" id="inputUsername" class="form-control"
value="{{ old('username') }}" placeholder="@lang('login.username')" required autofocus />
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="@lang('login.password')" required />
</div>@if (count($errors) > 0)
<p class="errors">
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
- <a href="@authurl('recover')" class="action-link">@lang('login.passwordRecovery')</a>
+ <a href="{{ authurl('recover') }}" class="action-link">@lang('login.passwordRecovery')</a>
</p>
@endif
<div id="remember" class="checkbox">
<label><input type="checkbox" name="remember">@lang('login.remember')</label>
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">@lang('login.loginButton')</button>
</form>
<!-- /form -->
@if (count($errors) == 0)
- <a href="@authurl('recover')" class="action-link">@lang('login.passwordRecovery')</a><br />
+ <a href="{{ authurl('recover') }}" class="action-link">@lang('login.passwordRecovery')</a><br />
@endif
- <a href="@authurl('register')" class="action-link">@lang('login.registerAccount')</a>
+ <a href="{{ authurl('register') }}" class="action-link">@lang('login.registerAccount')</a>
@endsection
diff --git a/resources/views/auth/recover.blade.php b/resources/views/auth/recover.blade.php
index cfc5873..5e90c0d 100644
--- a/resources/views/auth/recover.blade.php
+++ b/resources/views/auth/recover.blade.php
@@ -1,28 +1,28 @@
@extends('auth.master')
@section('card-content')
<h1 class="title">@lang('login.recoverAccess')</h1>
@if (session('status'))
<p class="success">{{ session('status') }}</p>
<p class="center"><img src="{{ url('/images/white-check.svg') }}" alt="Check mark" width="100px" /></p>
<p class="nav"><a href="{{ url('/') }}">@lang('pagination.previous') Back to login screen</a></p>
@else
- <form class="form-signin form-recover" role="form" method="POST" action="@authurl('recover')">
+ <form class="form-signin form-recover" role="form" method="POST" action="{{ authurl('recover') }}">
<div id="identity">
<input type="email" name="email" id="inputEmail" class="form-control"
value="{{ old('email') }}" placeholder="@lang('login.email')" required autofocus />
</div>@if (count($errors) > 0)
<p class="errors">
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
</p>
@endif
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">@lang('login.recoverButton')</button>
</form>
@endif
@endsection
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php
index 99ea3e7..1eebea1 100644
--- a/resources/views/auth/register.blade.php
+++ b/resources/views/auth/register.blade.php
@@ -1,33 +1,33 @@
@extends('auth.master')
@section('card-content')
<h1 class="title">@lang('login.registerAccount')</h1>
- <form class="form-signin form-register" role="form" method="POST" action="@authurl('register')">
+ <form class="form-signin form-register" role="form" method="POST" action="{{ authurl('register') }}">
<div id="identity">
<span id="reauth-username" class="reauth-username"></span>
<label for="inputUsername">@lang('login.username')</label>
<input type="text" name="username" id="inputUsername" class="form-control"
value="{{ old('username') }}" placeholder="@lang('login.usernamePlaceholder')" required autofocus />
<label for="inputFullname">@lang('login.fullname')</label>
<input type="text" name="fullname" id="inputFullname" class="form-control"
value="{{ old('fullname') }}" placeholder="@lang('login.fullnamePlaceholder')" autofocus />
<label for="inputEmail">@lang('login.email')</label>
<input type="email" name="email" id="inputEmail" class="form-control"
value="{{ old('email') }}" placeholder="@lang('login.emailPlaceholder')" required autofocus />
<label for="inputPassword">@lang('login.passwordBoth')</label>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="@lang('login.passwordPlaceholder')" required />
<input type="password" name="password_confirmation" id="inputPasswordConfirm" class="form-control" placeholder="@lang('login.passwordConfirmPlaceholder')" required />
</div>@if (count($errors) > 0)
<p class="errors">
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
</p>
@endif
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">@lang('login.registerButton')</button>
</form>
<!-- /form -->
@endsection
diff --git a/resources/views/auth/reset.blade.php b/resources/views/auth/reset.blade.php
index c0e4b1c..badb1e9 100644
--- a/resources/views/auth/reset.blade.php
+++ b/resources/views/auth/reset.blade.php
@@ -1,27 +1,27 @@
@extends('auth.master')
@section('card-content')
<div class="container-fluid">
<h1 class="title">@lang('login.resetPassword')</h1>
- <form class="form-signin form-reset" role="form" method="POST" action="@authurl('reset')">
+ <form class="form-signin form-reset" role="form" method="POST" action="{{ authurl('reset') }}">
<div id="identity">
<label for="inputEmail">@lang('login.email')</label>
<input type="email" name="email" id="inputEmail" class="form-control"
value="{{ old('email') }}" placeholder="@lang('login.emailPlaceholder')" required autofocus />
<label for="inputPassword">@lang('login.passwordBoth')</label>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="@lang('login.passwordPlaceholder')" required />
<input type="password" name="password_confirmation" id="inputPasswordConfirm" class="form-control" placeholder="@lang('login.passwordConfirmPlaceholder')" required />
</div>@if (count($errors) > 0)
<p class="errors">
@foreach ($errors->all() as $error)
{{ $error }}<br />
@endforeach
</p>
@endif
<input type="hidden" name="token" value="{{ $token }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit">@lang('login.resetButton')</button>
</form>
</div>
@endsection
diff --git a/resources/views/emails/password.blade.php b/resources/views/emails/password.blade.php
index 4d97a3e..94a1ab5 100644
--- a/resources/views/emails/password.blade.php
+++ b/resources/views/emails/password.blade.php
@@ -1,18 +1,18 @@
@extends('emails.master')
@section('mail-content')
@lang('emails.reset-password-intro')
@lang('emails.reset-password-login')
{{ $user->username }}
@lang('emails.reset-password-callforaction')
-@authurl('reset/{{ $token }}')
+{{ authurl("reset/$token") }}
@lang('emails.reset-password-origin')
{{ \Keruald\get_remote_addr() }}
@endsection
diff --git a/tests/Helpers/RoutingTest.php b/tests/Helpers/RoutingTest.php
new file mode 100644
index 0000000..1f39bb4
--- /dev/null
+++ b/tests/Helpers/RoutingTest.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace AuthGrove\Tests\Helpers;
+
+use AuthGrove\Tests\TestCase;
+
+class RoutingTest extends TestCase {
+
+ function testGetRoute () {
+ $this->assertStringEndsWith('/auth/login', authurl('login'));
+ $this->assertStringEndsWith('/auth', authurl());
+ $this->assertStringEndsWith('/auth', authurl(''));
+ $this->assertStringEndsWith('/auth', authurl(null));
+ $this->assertStringEndsWith('/auth', authurl(false));
+ $this->assertStringEndsWith('/auth/0', authurl(0));
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 18, 17:48 (12 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3176666
Default Alt Text
(15 KB)
Attached To
Mode
rGROVE Auth Grove
Attached
Detach File
Event Timeline
Log In to Comment