Mark's Place

A place for Mark's murmuring, blah, blah, blah, ...

Mark's Place
Watch Timeline

How to add password protection in CodeIgniter Scaffolding

Mark Wu 發表於 2009/10/06 10:50 · 靜態連結網址

It is really bad that CodeIgniter does not support password protection in scaffolding. I just go thorugh most scaffolding related posts in CodeIgniter forum, it seems no easy and clear solution for it. So, I just come out my own based on hooks function.

Here comes the code. Just follow it, and you will get a simple password protection for scaffolding:

1. Enable hook in your CodeIgniter application

application/config.php

[...]
$config['enable_hooks'] = TRUE;
[...]

2. Add a hook setting for pre-controller

application/hooks.php

[...]
$hook['pre_controller'][] = array(
                                'class'    => 'SimpleHttpAuth',
                                'function' => 'authenticate',
                                'filename' => 'SimpleHttpAuth.php',
                                'filepath' => 'hooks/SimpleHttpAuth',
                                'params'   => array()
                                );
[...]

 (閱讀全文)

迴響 (1) · 引用 (0) 文章分類: 可以做人幹嘛寫程式