SimpleAuth login
Closed this issue · 8 comments
Hello :),
I'm very interesting about Auth features.
It's seems that the SimpleAuth login function has not been implemented.
It does not store anything in session and i can't use it.
Is this a feature in progress or planned for the future ?
Or i make a mistake about usage ?
Thanks :)
Hi @Kevkehz !
The auth features are ready-to-use. Maybe there is a mistake in your app, or maybe a bug. If you provide some information to review it maybe I can help you 😃
- Your
application/config/hooks.php
file - Your
application/routes/web.php
file - Any code that you think is causing the issue.
- PHP version and OS version
Cheers.
Thank for your help :)
I'm running a server with laragon on Windows, PHP 5.6.
I start a new project from scratch and follow instructions from this page https://luthier.ingenia.me/ci/en/docs/authentication/simpleauth
hooks.php
$hook = Luthier\Hook::getHooks([
'modules' => ['Auth']
]);
routes/web.php
Route::auth();
Route::get('/', 'welcome@index')->name('homepage');
I can successfully signup, but when i try to login i get back on login page each time.
I get an empty response when running this function after login
$userObject = $this->simple_auth->user();
var_dump($userObject); // = null
I didn't get a flash message or anything.
In cookies i only have the ci_session cookie.
I supposed that the login feature was in this file luthier/src/Auth/SimpleAuth/Controller
, login
public function login()
{
$messages = Auth::messages();
$this->loadView('login', compact('messages'));
}
but I think the logic is somewhere else
I think that some configuration or routes are missing.
Please check the default value of auth_login_route_redirect
option in application/config/auth.php
:
$config['auth_login_route_redirect'] = 'dashboard';
In your routes, the dashboard
route is not defined, so the auth module maybe is redirecting you to the base_url
because that.
Try to clear all your cookies to delete any active session, and then update your web.php
route file with this test routing:
<?php
# application/routes/web.php
Route::auth(false);
Route::get('/', function(){
luthier_info();
})->name('homepage');
Route::group('secure', ['middleware' => 'SimpleAuthMiddleware'], function(){
Route::get('/', function(){
echo "Login succes!!";
})->name('dashboard');
});
Route::set('404_override', function(){
show_404();
});
Route::set('translate_uri_dashes',FALSE);
You should be redirected to the dashboard
route after log in. Let me know if that solves the issue.
After set Route::auth(); in the web.php route file i try to login, but another error.
INFO - 2018-07-20 08:33:43 --> Config Class Initialized INFO - 2018-07-20 08:33:43 --> Hooks Class Initialized DEBUG - 2018-07-20 08:33:43 --> UTF-8 Support Enabled INFO - 2018-07-20 08:33:43 --> Utf8 Class Initialized INFO - 2018-07-20 08:33:43 --> URI Class Initialized DEBUG - 2018-07-20 08:33:43 --> No URI present. Default controller set. INFO - 2018-07-20 08:33:43 --> Router Class Initialized INFO - 2018-07-20 08:33:43 --> Output Class Initialized INFO - 2018-07-20 08:33:43 --> Security Class Initialized DEBUG - 2018-07-20 08:33:43 --> Global POST, GET and COOKIE data sanitized INFO - 2018-07-20 08:33:43 --> Input Class Initialized INFO - 2018-07-20 08:33:43 --> Language Class Initialized INFO - 2018-07-20 08:33:43 --> Loader Class Initialized INFO - 2018-07-20 08:33:43 --> Database Driver Class Initialized INFO - 2018-07-20 08:33:43 --> Email Class Initialized INFO - 2018-07-20 08:33:43 --> Session: Class initialized using 'files' driver. INFO - 2018-07-20 08:33:43 --> Controller Class Initialized INFO - 2018-07-20 08:33:43 --> Helper loaded: url_helper ERROR - 2018-07-20 08:33:43 --> Severity: error --> Exception: Class 'Auth' not found /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Resources/About.php 62
Also in the root route (http://ci3.test)
An uncaught Exception was encountered
Type: Error
Message: Class 'Auth' not found
Filename: /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Resources/About.php
Line Number: 62
Backtrace:
File: /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Functions.php
Line: 67
Function: require
File: /Users/andrea/projects/ci3/application/routes/web.php
Line: 22
Function: luthier_info
File: /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Hook.php
Line: 422
Function: call_user_func_array
File: /Users/andrea/projects/ci3/vendor/luthier/luthier/src/Hook.php
Line: 59
Function: postControllerConstructorHook
File: /Users/andrea/projects/ci3/index.php
Line: 315
Function: require_once
Thank you
@abmcr make sure that you have enabled the Auth
module in the Luthier CI hooks:
# application/config/hooks.php
$hook = Luthier\Hook::getHooks([
'modules' => [ 'auth' , 'debug' ]
]);
in the doc there is an error
https://luthier.ingenia.me/ci/en/docs/authentication/authentication
The correct syntax is lowercase
$hook = Luthier\Hook::getHooks([
'modules' => [ 'auth' ]
]);
but in the doc ther is
$hook = Luthier\Hook::getHooks([
'modules' => [ 'Auth' ]
]);
thank you
Our apologies for the syntax error in the documentation, we will update the website soon. Thank you very much for letting us know @abmcr
Updated website documentation 👍