Skip to content

Commit 3306ed2

Browse files
committed
🔖 prepping for new release
1 parent 72a3a5b commit 3306ed2

File tree

5 files changed

+24
-56
lines changed

5 files changed

+24
-56
lines changed

App/Controllers/Controller.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
// Leaf Auth is a package which makes user authentication simple
66
use Leaf\Auth;
7-
use Leaf\Helpers\Password;
87

98
/**
109
* This is the base controller for your Leaf API Project.
@@ -13,32 +12,28 @@
1312
*/
1413
class Controller extends \Leaf\ApiController
1514
{
16-
/** @var \Leaf\Auth */
17-
public $auth;
18-
1915
public function __construct()
2016
{
2117
parent::__construct();
2218

2319
// In this version, request isn't initialised for you. You can use
2420
// requestData() or request() to get request data or initialise it yourself
25-
$this->auth = new Auth;
2621

2722
// autoConnect uses the .env variables to quickly connect to db
28-
$this->auth->autoConnect();
23+
Auth::autoConnect();
2924

3025
// set default token expiry time
31-
$this->auth->tokenLifetime(60 * 60 * 24 * 365);
26+
Auth::tokenLifetime(60 * 60 * 24 * 365);
3227

3328
// You can configure auth to get additional customizations
3429
// This can be done here with the Auth::config method or
3530
// simply in the Config/auth.php file
36-
$this->auth->config(authConfig());
31+
Auth::config(AuthConfig());
3732

3833
// You can refer to https://leafphp.netlify.app/#/leaf/v/2.4/core/auth for auth docs
3934

4035
// New in v2.5. This allows us to use session
4136
// authentication instead of the default API JWT method.
42-
$this->auth->useSession();
37+
Auth::useSession();
4338
}
4439
}

App/Routes/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
| Create a handler for 404 errors
99
|
1010
*/
11+
12+
use function Leaf\Traits\auth;
13+
1114
$app->set404(function() {
1215
response()->headers->status(404);
1316
response()->page(views_path("errors/404.html", false));

Config/functions.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ function app()
1010
}
1111
}
1212

13+
if (!function_exists('auth')) {
14+
/**
15+
* Return Leaf's auth object
16+
*/
17+
function auth($guard = null)
18+
{
19+
if (!$guard) return \Leaf\Auth::class;
20+
21+
if ($guard === 'session') {
22+
return \Leaf\Auth::session();
23+
}
24+
25+
return \Leaf\Auth::guard($guard);
26+
}
27+
}
28+
1329
if (!function_exists('d')) {
1430
/**
1531
* Return Leaf's date object
@@ -272,7 +288,7 @@ function view(string $view, array $data = [], array $mergeData = [])
272288
/**
273289
* Get an auth configuration
274290
*/
275-
function authConfig($setting = null)
291+
function AuthConfig($setting = null)
276292
{
277293
$config = require __DIR__ . "/auth.php";
278294
return !$setting ? $config : $config[$setting];

package.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

webpack.mix.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)