javascript - Not allowing a user to move forward to logging in until given access -


i trying figure out how deny user access signing in site unless have been approved. making site private allow join. can register, once they given permission/group level of 1 or 'bench'. once accept user , change permission level, able login.

as of now, stopping level/group 1 users redirect index page(where sign in at). however, want not allow them move forward next page @ all. reason being want display sort of pop alert displaying message created.

i'm not sure if can validation or way trying it. added on login code , attempting put permission code had on signed in page try stop start. basically, in attempt if user tries log in, script dies once sees permission level @ group 'bench'. pop alert displays saying why.

i'm not having success it. group/permission levels have name , id. have tried putting both in single quotatiob's 'bench' , '1', same error both.

fatal error: call member function haspermission() on non-object in /home4/pfarley1/public_html/example.com/index.php on line 12

i'm trying log them in this...

<?php if(input::exists()) { if(token::check(input::get('token'))) {      $validate = new validate();     $validation = $validate->check($_post, array(         'username' => array('required' => true),         'password' => array('required' => true)     )); // added line in if($user->haspermission('1')) {         die($permissionerror);}     if($validation->passed()) {         $user = new user();          $remember = (input::get('remember') === 'on') ? true : false;         $login = $user->login(input::get('username'), input::get('password'), $remember);          if($login) {             redirect::to('userindex.php');         } else {             $tryagain = '<span class="signinpanel">' . "the information entered did not match our records." . '</span>';         }      } else {         foreach($validation->errors() $error) {             echo $error, '<br>';         }     } } } ?> 

my permission code users..

public function haspermission($key) { $group = $this->_db->get('groups', array('id', '=', $this->data()->group));   if($group->count()) {         $permissions = json_decode($group->first()->permissions, true);          if($permissions[$key] == true) {             return true;         }     }     return false; } 

what doing wrong this or there better way this?

edit: last question wasn't specific enough, added info , there has been modification code in how trying this.

what $user on line 12?

if($user->haspermission('1')) { 

error message pretty explicit.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -