Пример #1
0
 public function login($postarray)
 {
     if (isset($postarray['email']) && isset($postarray['pwd']) && $postarray['email'] != '' && $postarray['pwd'] != '') {
         $usermodel = new User_Model_Users();
         $userDet = $usermodel->userDetails($postarray['email'], md5($postarray['pwd']));
         if (count($userDet) > 0) {
             if ($userDet[0]['user_role_id'] != 2) {
                 $userDetJson = array('status' => '0', 'message' => 'Not a privileged user.', 'result' => '');
             } else {
                 if ($userDet[0]['is_blocked'] == 1) {
                     $userDetJson = array('status' => '0', 'message' => 'User has been blocked.', 'result' => '');
                 } else {
                     if ($userDet[0]['is_active'] == 0) {
                         $userDetJson = array('status' => '0', 'message' => 'Not an active user.', 'result' => '');
                     } else {
                         unset($userDet[0]['user_role_id']);
                         unset($userDet[0]['is_blocked']);
                         unset($userDet[0]['is_active']);
                         $userDetJson = array('status' => '1', 'message' => 'Successfully logged in.', 'result' => $userDet);
                     }
                 }
             }
         } else {
             $userDetJson = array('status' => '0', 'message' => 'No user exist with the credentials.', 'result' => '');
         }
     } else {
         $userDetJson = array('status' => '0', 'message' => 'Email and Password should not be empty.', 'result' => '');
     }
     return $userDetJson;
 }
Пример #2
0
 public function loginAction()
 {
     //echo 'suresh';exit;
     $postarray = $this->getRequest()->getParams();
     if (isset($postarray['email']) && isset($postarray['pwd']) && $postarray['email'] != '' && $postarray['pwd'] != '') {
         $usermodel = new User_Model_Users();
         $userDet = $usermodel->userDetails($postarray['email'], md5($postarray['pwd']));
         if (count($userDet) > 0) {
             if ($userDet[0]['user_role_id'] != 2) {
                 $userDetJson = array('status' => '0', 'message' => 'Not a privileged user.', 'result' => '');
             } else {
                 if ($userDet[0]['is_blocked'] == 1) {
                     $userDetJson = array('status' => '0', 'message' => 'User has been blocked.', 'result' => '');
                 } else {
                     if ($userDet[0]['is_active'] == 0) {
                         $userDetJson = array('status' => '0', 'message' => 'Not an active user.', 'result' => '');
                     } else {
                         unset($userDet[0]['user_role_id']);
                         unset($userDet[0]['is_blocked']);
                         unset($userDet[0]['is_active']);
                         $userDetJson = array('status' => '1', 'message' => 'Successfully logged in.', 'result' => $userDet);
                     }
                 }
             }
         } else {
             $userDetJson = array('status' => '0', 'message' => 'No user exist with the credentials.', 'result' => '');
         }
     } else {
         $userDetJson = array('status' => '0', 'message' => 'Email and Password should not be empty.', 'result' => '');
     }
     //$testString = array(''=>'','result'=>'Created an action for restful web service.');
     //echo $testString;exit;
     $this->_helper->json($userDetJson);
 }