Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login_post()
- {
- $username = trim($this->post('username'));
- $password = trim($this->post('password'));
- if ($username == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username harus diisi.',
- ];
- } elseif ($password == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Password harus diisi.',
- ];
- } else {
- $checkUser = $this->db->get_where('ehealth_users', array('user_username' => $username))->row();
- if (count($checkUser) == 0) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username Tidak Terdaftar.',
- ];
- } else {
- if ($checkUser->user_status == 'Non Active') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Akun Anda belum di Aktifkan.',
- ];
- } else {
- $checkLogin = $this->db->get_where('ehealth_users', array('user_username' => $username, 'user_password' => sha1($password), 'user_status' => 'Active'))->row();
- if (count($checkLogin) == 0) {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Password Anda Salah.',
- ];
- } else {
- if ($checkLogin->user_image != '') {
- $avatar = base_url('icon/' . $checkLogin->user_image);
- } else {
- $avatar = base_url('img/no-avatar.png');
- }
- $response = [
- 'resp_error' => false,
- 'resp_msg' => 'success',
- 'username' => trim($checkLogin->user_username),
- 'nama' => trim($checkLogin->user_name),
- 'no_telp' => trim($checkLogin->user_phone),
- 'email' => trim($checkLogin->user_email),
- 'avatar' => $avatar,
- 'level' => trim($checkLogin->user_level),
- ];
- }
- }
- }
- }
- $this->response($response, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment