Community Auth problem with login |
Hello, I use commuinty auth for the first time and had some ideas, but they wont go right due lack of experience.
What I have done so far: authentication.php $config['levels_and_roles'] = array( '1' => 'an', '6' => 'ag', '9' => 'admin' ); $config['default_login_redirect'] = 'welcome'; $config['allowed_pages_for_login'] = array('welcome_message'); auth_constants.php define('LOGIN_PAGE', 'login'); routes.php $route[LOGIN_PAGE] = 'welcome/index'; and in welcome.php (controller) public function index() { if( $this->require_role('admin') ) { $this->load->view('admin_dashboard'); } elseif( $this->require_role('ag') ) { $this->load->view('ag_dashboard'); } elseif( $this->require_role('an') ) { $this->load->view('an_dashboard'); } else { $this->setup_login_form(); $this->load->view('welcome_message'); } } and public function login() { // Method should not be directly accessible if( $this->uri->uri_string() == 'login') show_404(); if( strtolower( $_SERVER['REQUEST_METHOD'] ) == 'post' ) $this->require_min_level(1); $this->setup_login_form(); $this->load->view('welcome_message'); } The problem is, I only can login with admin and get the page view of admin_dashboard. When I log in with another user it gives me the error: Login Error #3/5: Invalid Username, Email Address, or Password. Username, email address and password are all case sensitive. And in logfile I have this long pile I don't understand ??? INFO - 2016-02-29 18:48:11 --> Config Class Initialized INFO - 2016-02-29 18:48:11 --> Hooks Class Initialized DEBUG - 2016-02-29 18:48:11 --> UTF-8 Support Enabled INFO - 2016-02-29 18:48:11 --> Utf8 Class Initialized INFO - 2016-02-29 18:48:11 --> URI Class Initialized DEBUG - 2016-02-29 18:48:11 --> No URI present. Default controller set. INFO - 2016-02-29 18:48:11 --> Router Class Initialized INFO - 2016-02-29 18:48:11 --> Output Class Initialized INFO - 2016-02-29 18:48:11 --> Security Class Initialized DEBUG - 2016-02-29 18:48:11 --> Global POST, GET and COOKIE data sanitized INFO - 2016-02-29 18:48:11 --> Input Class Initialized INFO - 2016-02-29 18:48:11 --> Language Class Initialized INFO - 2016-02-29 18:48:11 --> Loader Class Initialized DEBUG - 2016-02-29 18:48:11 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/db_tables.php DEBUG - 2016-02-29 18:48:11 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/authentication.php INFO - 2016-02-29 18:48:11 --> Helper loaded: serialization_helper INFO - 2016-02-29 18:48:11 --> Helper loaded: cookie_helper INFO - 2016-02-29 18:48:11 --> Database Driver Class Initialized INFO - 2016-02-29 18:48:12 --> Session: Class initialized using 'database' driver. DEBUG - 2016-02-29 18:48:12 --> Encryption: Auto-configured driver 'openssl'. INFO - 2016-02-29 18:48:12 --> Encryption: OpenSSL initialized with method AES-128-CBC. INFO - 2016-02-29 18:48:12 --> Encryption Class Initialized INFO - 2016-02-29 18:48:12 --> Model Class Initialized INFO - 2016-02-29 18:48:12 --> Controller Class Initialized INFO - 2016-02-29 18:48:12 --> Helper loaded: url_helper INFO - 2016-02-29 18:48:12 --> Helper loaded: form_helper INFO - 2016-02-29 18:48:12 --> File loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\views\welcome_message.php INFO - 2016-02-29 18:48:12 --> Final output sent to browser DEBUG - 2016-02-29 18:48:12 --> Total execution time: 1.5964 INFO - 2016-02-29 18:48:12 --> Config Class Initialized INFO - 2016-02-29 18:48:12 --> Hooks Class Initialized DEBUG - 2016-02-29 18:48:12 --> UTF-8 Support Enabled INFO - 2016-02-29 18:48:12 --> Utf8 Class Initialized INFO - 2016-02-29 18:48:12 --> URI Class Initialized INFO - 2016-02-29 18:48:12 --> Router Class Initialized INFO - 2016-02-29 18:48:12 --> Output Class Initialized INFO - 2016-02-29 18:48:12 --> Security Class Initialized DEBUG - 2016-02-29 18:48:12 --> Global POST, GET and COOKIE data sanitized INFO - 2016-02-29 18:48:12 --> Input Class Initialized INFO - 2016-02-29 18:48:12 --> Language Class Initialized INFO - 2016-02-29 18:48:12 --> Loader Class Initialized DEBUG - 2016-02-29 18:48:12 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/db_tables.php DEBUG - 2016-02-29 18:48:12 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/authentication.php INFO - 2016-02-29 18:48:12 --> Helper loaded: serialization_helper INFO - 2016-02-29 18:48:12 --> Helper loaded: cookie_helper INFO - 2016-02-29 18:48:13 --> Database Driver Class Initialized INFO - 2016-02-29 18:48:14 --> Session: Class initialized using 'database' driver. DEBUG - 2016-02-29 18:48:14 --> Encryption: Auto-configured driver 'openssl'. INFO - 2016-02-29 18:48:14 --> Encryption: OpenSSL initialized with method AES-128-CBC. INFO - 2016-02-29 18:48:14 --> Encryption Class Initialized INFO - 2016-02-29 18:48:14 --> Model Class Initialized INFO - 2016-02-29 18:48:14 --> Controller Class Initialized INFO - 2016-02-29 18:48:14 --> Helper loaded: url_helper INFO - 2016-02-29 18:48:14 --> Helper loaded: form_helper INFO - 2016-02-29 18:48:14 --> File loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\views\welcome_message.php INFO - 2016-02-29 18:48:14 --> Final output sent to browser DEBUG - 2016-02-29 18:48:14 --> Total execution time: 1.5948 INFO - 2016-02-29 18:48:47 --> Config Class Initialized INFO - 2016-02-29 18:48:47 --> Hooks Class Initialized DEBUG - 2016-02-29 18:48:47 --> UTF-8 Support Enabled INFO - 2016-02-29 18:48:47 --> Utf8 Class Initialized INFO - 2016-02-29 18:48:47 --> URI Class Initialized INFO - 2016-02-29 18:48:47 --> Router Class Initialized INFO - 2016-02-29 18:48:47 --> Output Class Initialized INFO - 2016-02-29 18:48:47 --> Security Class Initialized DEBUG - 2016-02-29 18:48:47 --> Global POST, GET and COOKIE data sanitized INFO - 2016-02-29 18:48:47 --> Input Class Initialized INFO - 2016-02-29 18:48:47 --> Language Class Initialized INFO - 2016-02-29 18:48:47 --> Loader Class Initialized DEBUG - 2016-02-29 18:48:47 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/db_tables.php DEBUG - 2016-02-29 18:48:47 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/authentication.php INFO - 2016-02-29 18:48:47 --> Helper loaded: serialization_helper INFO - 2016-02-29 18:48:47 --> Helper loaded: cookie_helper INFO - 2016-02-29 18:48:47 --> Database Driver Class Initialized INFO - 2016-02-29 18:48:48 --> Session: Class initialized using 'database' driver. DEBUG - 2016-02-29 18:48:48 --> Encryption: Auto-configured driver 'openssl'. INFO - 2016-02-29 18:48:48 --> Encryption: OpenSSL initialized with method AES-128-CBC. INFO - 2016-02-29 18:48:48 --> Encryption Class Initialized INFO - 2016-02-29 18:48:48 --> Model Class Initialized INFO - 2016-02-29 18:48:48 --> Controller Class Initialized INFO - 2016-02-29 18:48:48 --> Helper loaded: url_helper INFO - 2016-02-29 18:48:48 --> Helper loaded: form_helper DEBUG - 2016-02-29 18:48:48 --> string = fritz password = Fritz15963 form_token = d5d1a255 token_jar = ["54ed0f7c","d5d1a255"] INFO - 2016-02-29 18:48:48 --> Form Validation Class Initialized INFO - 2016-02-29 18:48:48 --> Model Class Initialized DEBUG - 2016-02-29 18:48:48 --> Config file loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\third_party/community_auth/config/form_validation/login.php INFO - 2016-02-29 18:48:48 --> Language file loaded: language/english/form_validation_lang.php DEBUG - 2016-02-29 18:48:49 --> user is banned = no password in database = $2y$11$QbBwhfLw7.I.2tFKNEGLBe7yAkobuwUilTlX2pzatVjeKL1AUp4Ym supplied password match = 1 required level or role = admin auth level in database = 1 auth level equivalant role = an DEBUG - 2016-02-29 18:48:49 --> string = fritz password = Fritz15963 form_token = d5d1a255 token_jar = [] DEBUG - 2016-02-29 18:48:49 --> string = fritz password = Fritz15963 form_token = d5d1a255 token_jar = [] INFO - 2016-02-29 18:48:49 --> File loaded: C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\com_auth\ape\views\welcome_message.php INFO - 2016-02-29 18:48:49 --> Final output sent to browser DEBUG - 2016-02-29 18:48:49 --> Total execution time: 1.9356 Does anybody knows the solution of my problem ?
=:}
First, if you are changing your login page from "/login" to "/welcome/index", all you need to do is change the LOGIN_PAGE constant in auth_constants.php:
Code: define('LOGIN_PAGE', 'welcome'); This would mean that if somebody goes to the welcome URI, aka welcome/index, then they would be presented with the login page. If instead you want to use "/login" as your URI, and you want the welcome/index to handle the login page, just copy/modify the login method that comes inside controllers/Examples.php. Something like this: Code: public function index() That is just the login page, not a page for anything else. If you want an additional login page, then you must add that URI string to $config['allowed_pages_for_login'], but you haven't done that correctly, and I'm not sure what exactly you are trying to do. You have a welcome/login method, so it sounds like what you really wanted to do is change the LOGIN_PAGE constant to "welcome/login". Yes, you are for sure only going to be able to login as admin if your code is the way it is. Instead, you might try this: Code: if( $this->require_role('admin,ag,an') )
Sorry, I answer so late. Thank you for explanations. Now I got the solution, which is doing what I really wanted.
But this is only the beginning of many questions. My solution for this time -> following your guide: This page, where the loginpage shows up: define('LOGIN_PAGE', 'welcome'); This page, where you go after login page: $route[LOGIN_PAGE] = 'welcome/login'; authentication.php $config['default_login_redirect'] = 'welcome'; $config['allowed_pages_for_login'] = array('welcome_message'); welcome.php class Welcome extends My_Controller { ... public function index() { if( $this->uri->uri_string() == 'welcome') show_404(); if( strtolower( $_SERVER['REQUEST_METHOD'] ) == 'post' ) $this->require_min_level(1); $this->setup_login_form(); $this->load->view('welcome_message'); } public function login() { if( $this->require_role('admin,ag,an') ) { $this->load->view( $this->auth_role.'_dashboard' ); } else { $this->setup_login_form(); $this->load->view('welcome_message'); } } ... } Like this I am fine for the moment, thank you.
=:}
(03-02-2016, 08:53 AM)yettie Wrote: Sorry, I answer so late. Thank you for explanations. Now I got the solution, which is doing what I really wanted. I'm glad you figured it out. In the future, it would be beneficial for you to format your code using bbcode. It'll keep your whitespace and make it easier for me to help you. |
Welcome Guest, Not a member yet? Register Sign In |