Changeset 64
- Timestamp:
- 04/13/07 06:32:15
- Files:
-
- FreakAuth/trunk/www/public/css/style.css (modified) (1 diff)
- FreakAuth/trunk/www/system/application/config/freakauth_light.php (modified) (1 diff)
- FreakAuth/trunk/www/system/application/controllers/example.php (modified) (1 diff)
- FreakAuth/trunk/www/system/application/libraries/Freakauth_light.php (modified) (2 diffs)
- FreakAuth/trunk/www/system/application/views/FreakAuth_light/template/denied.php (added)
- FreakAuth/trunk/www/system/application/views/FreakAuth_light/template/example.php (added)
- FreakAuth/trunk/www/system/application/views/FreakAuth_light/template/menu.php (modified) (1 diff)
- FreakAuth/trunk/www/system/language/english/freakauth_lang.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
FreakAuth/trunk/www/public/css/style.css
r2 r64 112 112 padding-bottom: 24px; 113 113 margin: 0; 114 margin-left: 250px;}114 margin-left: 190px;} 115 115 116 116 ul#navlist li {float: left; FreakAuth/trunk/www/system/application/config/freakauth_light.php
r36 r64 23 23 24 24 $config['FAL'] = TRUE; //TRUE/FALSE (boolean). Whether the FreakAuth system is turned on. 25 26 $config['FAL_flash'] = TRUE; //boolean: if TRUE uses FLASH messages and redirect if not allowed 27 // if FALSE loads the page you defined in $config['FAL_denied_page'] 28 $config['FAL_denied_page'] = 'FreakAuth_light/template/denied'; //if we don't want to use a flash message 29 //the page/view we want to load to display the deny message 25 30 26 31 $config['FAL_create_user_profile'] = TRUE; //TRUE/FALSE (boolean). Whether to use custom user profile FreakAuth/trunk/www/system/application/controllers/example.php
r56 r64 14 14 function index() 15 15 { 16 17 echo '<h1>You can view this message because you logged in and are at least an user!</h1>'; 18 echo 'You are <b>'.getUserName().'</b> (role:<b>'.getUserProperty('role').'</b>),'; 19 echo ' your id is <b>'.getUserProperty('id').'</b>.<br />'; 20 echo 'Your superadmin is <b>'.getUserPropertyFromId(1,'user_name').'</b>.'; 16 $this->load->view($this->config->item('FAL_template_dir').'template/example'); 21 17 } 22 18 } FreakAuth/trunk/www/system/application/libraries/Freakauth_light.php
r56 r64 128 128 function check($_lock_to_role=null, $_only=null) 129 129 { 130 131 130 132 131 //check who did the request and build role hierarchy … … 166 165 if ($_condition==false) 167 166 { 168 //set a flash message 169 $msg = "You do not have the credentials to access this reserved area"; 170 $this->CI->db_session->set_flashdata('flashMessage', $msg, 1); 171 redirect('', 'location'); 172 } 167 $this->deny($_who_is); 168 } 173 169 } 174 170 //it means it is a guest because it has no role stored in DB_session 175 else 176 { 177 redirect('auth/index', 'location');171 else 172 { 173 $this->deny($_who_is); 178 174 } 179 175 } 180 176 177 // -------------------------------------------------------------------- 178 179 /** 180 * Handles the case where the one who did the request 181 * doesn't have enough credentials 182 * 183 * if FAL_flash == true in config file, displays a flash message 184 * and redirect to the referer page (or root if none) 185 * 186 * else displays the FAL_denied_page (see config file) 187 * 188 * @param $role : the role of the one we are denying the access 189 */ 190 function deny($role) 191 { 192 $this->CI->lang->load('freakauth'); 193 if ($this->CI->config->item('FAL_flash')) 194 { 195 if ($role == '') 196 { 197 $msg = $this->CI->lang->line('FAL_no_credentials_guest'); 198 $this->CI->db_session->set_flashdata('flashMessage', $msg, 1); 199 redirect('auth', 'location'); 200 exit(); 201 } 202 else 203 { 204 $msg = $this->CI->lang->line('FAL_no_credentials_user'); 205 $this->CI->db_session->set_flashdata('flashMessage', $msg, 1); 206 207 // redirect where we were previously 208 if (isset($_SERVER['HTTP_REFERER'])) 209 { 210 header("location:".$_SERVER['HTTP_REFERER']); 211 exit(); 212 } 213 else 214 { 215 redirect('', 'location'); 216 } 217 exit(); 218 } 219 } 220 else 221 { 222 $page = $this->CI->config->item('FAL_denied_page'); 223 $data['role'] = $role; 224 // this is how we stop the execution 225 echo $this->CI->load->view($page, $data, true); 226 exit(); 227 } 228 } 229 230 231 181 232 // -------------------------------------------------------------------- 182 233 FreakAuth/trunk/www/system/application/views/FreakAuth_light/template/menu.php
r2 r64 2 2 <ul id="navlist"> 3 3 <li id="active"><?=anchor('', 'home')?></li> 4 <li><?=anchor('auth/', 'login')?></li> 4 <li><?=anchor('example', 'example')?></li> 5 <li><?=anchor('auth', 'login')?></li> 5 6 <li><?=anchor('auth/register', 'register')?></li> 6 7 <li><?=anchor('auth/forgotten_password', 'forgotten password')?></li> 7 8 <li><?=anchor('auth/changepassword', 'change password')?></li> 8 <li><?=anchor('admin /', 'admin')?></li>9 <li><?=anchor('admin', 'admin')?></li> 9 10 </ul> 10 11 </div> FreakAuth/trunk/www/system/language/english/freakauth_lang.php
r61 r64 40 40 41 41 $lang['FAL_unknown_user'] = 'unknown user'; 42 43 $lang['FAL_no_credentials_guest'] = 'You do not have the credentials to access this reserved area, please login and retry.'; 44 $lang['FAL_no_credentials_user'] = 'You do not have the credentials to access this reserved area.'; 42 45 43 46 //------------------------------------------------------------------
