Browse Source

admin and superadmin as usergroups.

master
Rogier Neeleman 9 years ago
parent
commit
d9159bed02
  1. 12
      application/migrations/20160304220000_add_user.php
  2. 4
      application/models/Login_model.php

12
application/migrations/20160304220000_add_user.php

@ -29,6 +29,18 @@ class Migration_Add_user extends CI_Migration
'type' => 'VARCHAR', 'type' => 'VARCHAR',
'constraint' => '80', 'constraint' => '80',
), ),
'admin' => array(
'type' => 'INT',
'constraint' => '1',
'unsigned' => TRUE,
'default' => '0',
),
'superadmin' => array(
'type' => 'INT',
'constraint' => '1',
'unsigned' => TRUE,
'default' => '0',
),
)); ));
$this->dbforge->add_key('id', TRUE); $this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('user'); $this->dbforge->create_table('user');

4
application/models/Login_model.php

@ -20,7 +20,7 @@ class Login_model extends CI_Model
$regioid = $this->security->xss_clean($this->input->post('regioid')); $regioid = $this->security->xss_clean($this->input->post('regioid'));
// Search for user // Search for user
$this->db->select('id, regioid'); $this->db->select('id, regioid, admin, superadmin');
$this->db->where('username', $username); $this->db->where('username', $username);
$this->db->where('password', sha1($password)); $this->db->where('password', sha1($password));
$this->db->where('regioid', $regioid); $this->db->where('regioid', $regioid);
@ -35,6 +35,8 @@ class Login_model extends CI_Model
$userdata = array( $userdata = array(
'id' => $row->id, 'id' => $row->id,
'regio' => $row->regioid, 'regio' => $row->regioid,
'admin' => $row->admin,
'superadmin' => $row->superadmin,
'validated' => true 'validated' => true
); );

Loading…
Cancel
Save