Welcome Guest, Not a member yet? Register   Sign In
Hook - Community Auth
#1

Hello,

I'm trying to use Community Auth on a fresh CodeIgniter install version 3.0.6.

I follow all the installation guide but when I try to use, I have this message

Code:
A PHP Error was encountered
[color=#4f5155][size=small]Severity: Notice[/size][/color]
[color=#4f5155][size=small]Message: Use of undefined constant LOGIN_PAGE - assumed 'LOGIN_PAGE'[/size][/color]
[color=#4f5155][size=small]Filename: config/routes.php[/size][/color]
[color=#4f5155][size=small]Line Number: 52[/size][/color]
[color=#4f5155][size=small]Backtrace:[/size][/color]
[color=#4f5155][size=small]File: [color=#4f5155][size=small][font=Monaco, Consolas, Courier, monospace]...[/font][/size][/color]/application/config/routes.php
Line: 52
Function: _error_handler[/size][/color]
File: .../index.php
Line: 315
Function: require_once

The hook files are setup correctly and I configure the hooks.php in the config folder.

If I try to add "echo 'test';" in the function auth_constants, nothing happend.

Any idea ?
Reply
#2

I found my miste... The hooks are disabled in config.php Smile

But I have another question, you use for example in your Examples controller, $this->require_role('admin').

How can I call the same function in another controller ?
Reply
#3

LOGIN_PAGE is defined in the auth_constants hook, and it's a pre_system hook. In config/config you should set enable_hooks to TRUE.

There is no magic here. Either auth_constants hook runs because it's set up correctly or not.

Note installation step 5:
5) Copy auth_constants.php and auth_sess_check.php from community_auth/hooks to CodeIgniter's application/hooks directory.

If these files are in your application/hooks directory, you've enabled hooks in config/config, and put the following in config/hooks.php, then it should work:

Code:
$hook['pre_system'] = array(
    'function' => 'auth_constants',
    'filename' => 'auth_constants.php',
    'filepath' => 'hooks'
);
$hook['post_system'] = array(
    'function' => 'auth_sess_check',
    'filename' => 'auth_sess_check.php',
    'filepath' => 'hooks'
);
Reply
#4

I'm wondering the same thing he asked at the end Skunkbad

"How can I call the same function in another controller ?"
Reply
#5

(08-15-2016, 12:43 AM)easymusic Wrote: I'm wondering the same thing he asked at the end Skunkbad

"How can I call the same function in another controller ?"

Instead of your controller class extending CI_Controller, just have it instead extend MY_Controller. That's it.
Reply
#6

(08-15-2016, 07:04 AM)skunkbad Wrote:
(08-15-2016, 12:43 AM)easymusic Wrote: I'm wondering the same thing he asked at the end Skunkbad

"How can I call the same function in another controller ?"

Instead of your controller class extending CI_Controller, just have it instead extend MY_Controller. That's it.
 Thanks skunk, haha your amazing, it worked. Thanks for all the hardwork (Community Auth) !
Reply




Theme © iAndrew 2016 - Forum software by © MyBB