/** * Authenticate user and login into the system. * * @param \Cygnite\Http\Requests\Request $request * @return array */ public function checkAction(Request $request) { $crypt = new Encrypt(); $credentials = ['username' => $request->post->get('username'), 'password' => $crypt->encode($request->post->get('password'))]; if ($this->auth->credential($credentials)->login()) { $userInfo = $this->auth->userInfo(); return ['status' => true, 'user' => $userInfo]; } return ['status' => false, 'user' => []]; }
/** * Authenticate user and login into the system * */ public function checkAction() { $input = Input::make(); $post = $input->json(); $crypt = new Encrypt(); $credentials = array('email' => $post->email, 'password' => $crypt->encode($post->password)); if ($this->auth->verify($credentials)) { $this->auth->login(); $userInfo = $this->auth->userInfo(); echo json_encode(array('success' => true, 'flash' => 'Logged In Successfully!!', 'name' => $userInfo['name'])); } else { echo json_encode(array('success' => false, 'flash' => 'Invalid username or password', 'name' => '')); } }