public function postLogin() { $data = Input::only('email', 'password'); $userObj = new User(); $login = $userObj->loginUser($data['email'], $data['password']); if ($login) { return Redirect::to('admin/schedules'); //return Response::json(array('status' => '1',array('user' => $login->toArray()))); } }
public function postLogin() { $data = Input::only('email', 'password'); $userObj = new User(); $login = $userObj->loginUser($data['email'], $data['password']); if ($login) { // Filter will take the decision $homeSlides = HomeSlides::get(); return View::make('backend.homeSlidelist')->with('homeSlides', $homeSlides); //return Response::json(array('status' => '1',array('user' => $login->toArray()))); } }
public function ajaxAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $user = new User(); $params = $this->getAllParams(); if (isset($params['case'])) { switch ($params['case']) { case 'registerUser': $this->result = $user->registerUser($params); break; case 'loginUser': $this->result = $user->loginUser($params); break; case 'logoutUser': $this->result = $user->logoutUser(); break; case 'forgotPassword': $this->result = $user->userForgotPassword($params); break; case 'savePersonalData': $this->result = $user->savePersonalData($params); break; case 'saveSettingsData': $this->result = $user->saveSettingsData($params); break; case 'search': $this->result = $this->searchRequest($params); break; default: $this->result = []; break; } } /* disable feedback post*/ header("Content-Type: text/json"); echo json_encode($this->result); }
/** * Login form setup session and remember me cookie */ public function loginAction() { $this->view->dbs = false; if ($this->isUserAuthenticated()) { return $this->response->redirect(); } $this->view->showMenu = false; if ($this->request->isPost()) { $auth = $this->request->get('auth'); $user = User::loginUser($auth['email'], $auth['pass']); if ($user) { $this->session->set("user-data", $user); if (isset($auth['cookie'])) { $this->cookies->set('remember-me', $user->setUserCookieHash(), time() + 30 * 86400); } if ($ref = $this->request->getHTTPReferer()) { return $this->response->redirect($ref); } return $this->response->redirect(); } else { $this->flash->error('<b>Autentication faild!</b> Email or password incorect.'); } } }
if (empty($_POST["email"])) { $email_error = "E-mail on kohustuslik"; } else { $email = test_input($_POST["email"]); } if (empty($_POST["password"])) { $password_error = "Parool on kohustuslik"; } else { $password = test_input($_POST["password"]); } // Kui oleme siia joudnud, voime kasutaja sisse logida if ($password_error == "" && $email_error == "") { echo "Saab sisse logida! Kasutajanimi on " . $email . " ja parool on " . $password; $password_hash = hash("sha512", $password); echo $password_hash; $login_response = $User->loginUser($email, $password_hash); if (isset($login_response->success)) { // läks edukalt, nüüd peaks kasutaja sessiooni salvestama $_SESSION["id_from_db"] = $login_response->success->user->id; $_SESSION["user_email"] = $login_response->success->user->email; header("Location: 3data.php"); exit; } } } // ********************* // ** LOO KASUTAJA ***** // ********************* if (isset($_POST["create"])) { echo "vajutas create nuppu!"; if (empty($_POST["name"])) {
//kontrollin, et e-post ei ole tühi if (empty($_POST["email"])) { $email_error = "This field is mandatory"; } else { $email = test_input($_POST["email"]); } //kontrollin, et parool ei ole tühi if (empty($_POST["password"])) { $password_error = "This field is mandatory"; } else { $password = test_input($_POST["password"]); } // võib sisse logida if ($password_error == "" && $email_error == "") { $hash = hash("sha512", $password); $login_response = $User->loginUser($email, $hash, $person_id); var_dump($login_response); //kasutaja logis edukalt sisse if (isset($login_response->success)) { $_SESSION["logged_in_user_id"] = $login_response->user->id; $_SESSION["logged_in_user_email"] = $login_response->user->email; //saadan sõnumi teise faili kasutades SESSIOONI $_SESSION["login_success_message"] = $login_response->success->message; header("Location: data.php"); } } } elseif (isset($_POST["create"])) { if (empty($_POST["person_id"])) { $person_id_error = "This field is mandatory"; } else { $person_id = test_input($_POST["person_id"]);
//check if some parrams are missing if (empty($_POST['username']) || empty($_POST['password'])) { returnError('Missing or empty post parameters.'); } $username = $_POST['username']; $password = $_POST['password']; if (!ctype_alpha($username)) { returnError('All username chars must be english letters.'); } if (preg_match('/\\s/', $password)) { returnError('Password can`t contain any whitespaces.'); } if (strlen($password) < 6) { returnError('Password must be longer then five characters.'); } $u = new User(); $u->loginUser($username, $password); }); //POST ROUTE REMOVE $app->post('/remove', function () { //check if some parrams are missing if (empty($_POST['username']) || empty($_POST['password'] || empty($_POST['token']))) { returnError('Missing or empty post parameters.'); } $username = $_POST['username']; $password = $_POST['password']; $token = $_POST['token']; $u = new User(); $test = $u->removeUser($username, $password, $token); }); $app->run();
function loginUser() { include_once "../model/User.php"; $user = new User(); $username = $_REQUEST['username']; $password = $_REQUEST['password']; $user_type = $_REQUEST['user_type']; if (!$user->loginUser($username, $password, $user_type)) { //login is unsuccessful echo '{"result": 0, "message": "Login is unsuccessful"}'; return; } else { echo '{"result": 1, "message": "Login is successful"}'; return; } }
//kontrollin, et e-post ei ole tühi if (empty($_POST["email"])) { $email_error = "This field is mandatory"; } else { $email = test_input($_POST["email"]); } //kontrollin, et parool ei ole tühi if (empty($_POST["password"])) { $password_error = "This field is mandatory"; } else { $password = test_input($_POST["password"]); } // võib sisse logida if ($password_error == "" && $email_error == "") { $hash = hash("sha512", $password); $login_response = $User->loginUser($email, $hash); var_dump($login_response); //kasutaja logis edukalt sisse if (isset($login_response->success)) { $_SESSION["logged_in_user_id"] = $login_response->user->id; $_SESSION["logged_in_user_email"] = $login_response->user->email; $_SESSION["name"] = $login_response->user->fullname; //saadan sõnumi teise faili kasutades SESSIOONI $_SESSION["login_success_message"] = $login_response->success->message; header("Location: data.php"); } } } elseif (isset($_POST["create"])) { if (empty($_POST["username"])) { $name_error = "This field is mandatory"; } else {