multi-tenant access using the same db
I am reviewing what's the best approach to building an application that would use the same database for multiple clients. It's not necessarily different websites, but just have different users from different companies use the same backend with their own data. Has anyone done this before?
Comments
function list_items($limit = NULL, $offset = NULL, $col = 'date_added', $order = 'desc') { $CI =& get_instance(); $this->db->where(array('my_table.user_id' => $CI->fuel_auth->user_data('id')) $data = parent::list_items($limit, $offset, $col, $order); return $data; }
How about edit, delete?
I login as normal user and actually do an edit on another user by guessing the id another user. It goes to edit page another user.
Ex: fuel/mysimplemodel/edit/25
35 is my userid ( I created 25 and hence can edit the record)
now another userid 45 when he login to system if he accesses to
fuel/mysimplemodel/edit/25 - he goes to edit page.
how do we block edit and other options from illegal modifications to data.
Only admin should have liberty to modify this.
(Totally unsecure right)?
$CI =& get_instance();
$user = $CI->fuel_auth->user_data();
if(($user['super_admin']== 'no')) {
$this->session->set_flashdata('error', 'You do not have access to edit/view this account!');
redirect(fuel_url('XXXXXXXX'));
}
if( (isset($values['userid']) && $values['userid'] != $user['id'])) {
$this->session->set_flashdata('error', 'You do not have access to edit/view this account!');
redirect(fuel_url('XXXXX'));
}
Can some one comment - if the code snippet is right and right place to be in?