/** * 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' => '')); } }
public function setUp() { $this->configure(); $this->crypt = Encrypt::create(); }
/** * Retrieve a session variable * * @false string $name Name of the variable you are looking for * @param $key * @param null $defaultValue * @return mixed */ public function get($key = null, $defaultValue = null) { if ($key == null && $defaultValue == null) { return $this->session; } else { switch ($key) { case is_array($this->session[$key]): /** @var $key TYPE_NAME */ return isset($this->session[$key]) ? $this->session[$key] : $defaultValue; break; case is_string($this->session[$key]): return isset($this->session[$key]) ? Encrypt::instance()->decode($this->session[$key]) : $defaultValue; break; } } }