public function register(Request $request)
 {
     $user = new User();
     $userService = new UserService();
     $uservalidator = new UserValidator();
     $response = array();
     if (!$uservalidator->userRegistrationValidator($request)) {
         $response = array("status" => "failure", "message" => "Validation Error Occurs");
     } else {
         $user->first_name = $request->firstName;
         $user->last_name = $request->lastName;
         $user->email_id = $request->emailId;
         $user->password = $request->password;
         $response = $userService->createuser($user);
     }
     return $response;
 }
예제 #2
0
 public function login(Request $request)
 {
     $user = new User();
     $userService = new UserService();
     $uservalidator = new UserValidator();
     $response = new Response();
     $constants = new AppConstants();
     if (!$uservalidator->userLoginValidator($request)) {
         $response->setResponseStatus($constants->FAILURE());
         $response->setResponseMessage($constants->USER_VALIDATION_ERROR_MESSAGE());
     } else {
         $user->user_email = $request->user_email;
         $user->user_password = $request->user_password;
         $result = $userService->loginuser($user);
         if ($result == $constants->LOGIN_SUCCESS_STATUS()) {
             $response->setResponseStatus($constants->SUCCESS());
             $response->setResponseMessage($constants->LOGIN_SUCCESS_MESSAGE());
             $userid = $userService->getUserID($user);
             $session = $userService->createSession($userid);
             $responsibility = $userService->getResponsibility($userid);
             $menu = $userService->getMenu($userid);
         } else {
             $response->setResponseStatus($constants->FAILURE());
             $response->setResponseMessage($constants->LOGIN_FAILURE_MESSAGE());
             $session = "";
             $responsibility = "";
             $menu = "";
         }
     }
     return json_encode(array("status" => $response->getResponseStatus(), "message" => $response->getResponseMessage(), "Response" => array("Session" => $session, "Responsibility" => $responsibility, "Menu" => $menu)));
 }