PHP Method User::auth, codiad Code Examples

This page contains top rated real world PHP examples of method User::auth from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: UserController.php Project: RybalkoA/st
0
 public function actionLogin()
 {
     $login = '';
     $pass = '';
     if (isset($_POST['ok'])) {
         $login = $_POST['login'];
         $pass = $_POST['pass'];
         $errors = FALSE;
         if (!User::checkPass($pass)) {
             $errors[] = 'Пароль не должен быть меньше 6-ти символов';
         }
         if (!User::checkLogin($login)) {
             $errors[] = 'Логин не должен быть меньше 4-х символов';
         }
         $userId = User::checkUserData($login, $pass);
         if ($userId == FALSE) {
             $errors[] = 'Не верные логин и пароль';
         } else {
             User::auth($userId);
             header("location:/st/main/");
         }
     }
     require_once ROOT . '/views/user/auth.php';
     return TRUE;
 }
Example #2
Show file File: FWUser.class.php Project: hbdsklf/LimeCMS
0
 /**
  * Verify user authentication
  * @return  boolean           True if authentication is okay,
  *                            false otherwise
  */
 function checkAuth()
 {
     global $sessionObj, $_CORELANG;
     $username = isset($_POST['USERNAME']) && $_POST['USERNAME'] != '' ? contrexx_stripslashes($_POST['USERNAME']) : null;
     $password = isset($_POST['PASSWORD']) && $_POST['PASSWORD'] != '' ? md5(contrexx_stripslashes($_POST['PASSWORD'])) : null;
     $authToken = !empty($_GET['auth-token']) ? contrexx_input2raw($_GET['auth-token']) : null;
     $userId = !empty($_GET['user-id']) ? contrexx_input2raw($_GET['user-id']) : null;
     if ((!isset($username) || !isset($password)) && (!isset($authToken) || !isset($userId))) {
         return false;
     }
     if (empty($sessionObj)) {
         $sessionObj = cmsSession::getInstance();
     }
     if (!isset($_SESSION['auth'])) {
         $_SESSION['auth'] = array();
     }
     if (isset($username) && isset($password) && $this->objUser->auth($username, $password, $this->isBackendMode(), \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) || isset($authToken) && isset($userId) && $this->objUser->authByToken($userId, $authToken, $this->isBackendMode())) {
         if ($this->isBackendMode()) {
             $this->log();
         }
         $this->loginUser($this->objUser);
         return true;
     }
     $_SESSION['auth']['loginLastAuthFailed'] = 1;
     User::registerFailedLogin($username);
     $this->arrStatusMsg['error'][] = $_CORELANG['TXT_PASSWORD_OR_USERNAME_IS_INCORRECT'];
     $_SESSION->cmsSessionUserUpdate();
     $_SESSION->cmsSessionStatusUpdate($this->isBackendMode() ? 'backend' : 'frontend');
     return false;
 }
Example #3
Show file File: Index.php Project: rx-projects/comicasa
0
 public function invokeHandler(Smarty $viewModel, $header, $f, $page, User $user)
 {
     $header->meta(array('keywords' => 'Home Meta Keywords', 'description' => 'Home Meta Description'));
     $header->title('RUDRAX');
     $header->import('bootstrap', 'utils', 'product_login', 'utils_tunnel');
     $cahce = new RxCache();
     $page->data->assign('myDataKey', $cahce->get('mykey'));
     $cahce->set('mykey', $cahce->get('mykey') + 1);
     if (isset($_REQUEST['uname'])) {
         $username = $_POST['uname'];
         $password = $_POST['pass'];
         $user->auth($username, $password);
     }
     //Console::log($this->user->getToken(),$username,$password);
     if ($user->isValid()) {
         $viewModel->assign('token', $user->getToken());
         $viewModel->assign('profile', $user->getProfile());
         $viewModel->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
         $viewModel->assign("FirstName", array("John", "Mary", "James", "Henry"));
         $viewModel->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
         $viewModel->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), array("M", "N", "O", "P")));
         $viewModel->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
         $viewModel->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
         $viewModel->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
         $viewModel->assign("option_selected", "NE");
         return "home/home";
     } else {
         return "sample/login";
     }
 }
Example #4
Show file File: UserController.php Project: bogwien/first.mystore.loc
0
 public function actionLogin()
 {
     $userData = array('name' => '', 'email' => '', 'password' => '');
     if (isset($_POST['submit'])) {
         $user = new User('', $_POST['email'], $_POST['password']);
         $errors = false;
         if (!$user->checkEmail()) {
             $errors[] = 'Неправильный email';
         }
         if (!$user->checkPassword()) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         if (empty($errors)) {
             $userAuth = $user->checkUserData();
             if ($userAuth) {
                 $user->auth();
                 header("Location: /cabinet/");
             } else {
                 $errors[] = 'Неправельные данные для авторизации';
             }
         }
         $userData = $user->getUserData();
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #5
Show file File: UserController.php Project: joe-lumarlin/oleis_shop
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $error = false;
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправльный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6 символов';
         }
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправльные данные для входа на сайт';
         } else {
             User::auth($userId);
             header('Location: /cabinet/');
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #6
Show file File: UserController.php Project: php-user/shop.local
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     $remember = '';
     if (isset($_POST['submit'])) {
         $email = FunctionLibrary::clearStr($_POST['email']);
         $password = FunctionLibrary::clearStr($_POST['password']);
         if (isset($_POST['remember'])) {
             $remember = FunctionLibrary::clearStr($_POST['remember']);
         }
         $errors = array();
         if (!User::checkEmail($email)) {
             $errors[] = 'Невалидный email.';
         }
         $user = User::login($email, $password, $remember);
         if ($user) {
             User::auth($user);
             FunctionLibrary::redirectTo('/cabinet');
         } else {
             $errors[] = 'Неправильные данные для входа на сайт.';
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #7
Show file File: UserController.php Project: scorpion1986/site
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //validarea cimpurilor
         if (!User::checkEmail($email)) {
             $errors[] = 'Nu este corect emailul';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Parola nu trebue sa fie mai scurta de 6 simboluri';
         }
         //verificam daca exista utilizatorul
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             //Daca datele nu sunt corecte afisham eroare
             $errors[] = 'Datele is incorecte , pentru a intra pe site';
         } else {
             //daca datele is corecte , memoram utilizatorul in sesiune
             User::auth($userId);
             //directionam utilizatorul in partea inchisa a cabinetului
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #8
Show file File: UserController.php Project: KazakovVS/Store
0
 /**
  * Action для страницы "Вход на сайт"
  */
 public function actionLogin()
 {
     $email = false;
     $password = false;
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             // Если данные правильные, запоминаем пользователя (сессия)
             User::auth($userId);
             header("Location: /cabinet");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #9
Show file File: Permission.php Project: joswilson/NotJustOK
0
 public function __construct()
 {
     parent::__construct();
     $bUserAuth = User::auth();
     $bAdminAuth = AdminCore::auth();
     /***** Levels for members *****/
     // Overall levels
     if (!$bUserAuth && ($this->registry->controller === 'AccountController' && $this->registry->action !== 'activate' || $this->registry->controller === 'FriendController' && $this->registry->action === 'mutual' || $this->registry->action === 'logout')) {
         $this->signUpRedirect();
     }
     if (!$bUserAuth && !$bAdminAuth && $this->registry->controller === 'SettingController') {
         $this->signUpRedirect();
     }
     if ($bUserAuth && ($this->registry->controller === 'SignupController' || $this->registry->action === 'activate' || $this->registry->action === 'resendactivation' || $this->registry->action === 'login')) {
         $this->alreadyConnectedRedirect();
     }
     // Options and Memberships ...
     if (!$bAdminAuth) {
         if (!$this->checkMembership() || $bUserAuth && !$this->group->member_site_access) {
             $this->paymentRedirect();
         } elseif ($this->registry->controller === 'SearchController') {
             if (!$this->group->quick_search_profiles || !$this->group->advanced_search_profiles) {
                 $this->paymentRedirect();
             }
         }
     }
 }
Example #10
Show file File: UserController.php Project: Evkazolinium/Eshop_for_example
0
 public function actionLogin()
 {
     $result = false;
     $password = '';
     $email = '';
     if (isset($_POST['submit'])) {
         $password = $_POST['password'];
         $email = $_POST['email'];
         $errors = false;
         if (!User::validateEmail($email)) {
             $errors[] = "Неккоректный email";
         }
         if (!User::validatePassword($password)) {
             $errors[] = "Пароль должен быть больше 3 символов";
         }
         $userId = User::validateUserData($email, $password);
         if ($userId == false) {
             $errors[] = "Некорректные данные для входа на сайт";
         } else {
             User::auth($userId);
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #11
Show file File: UserController.php Project: KGB-Steam/test
0
 function actionRegister()
 {
     $error = '';
     if (User::auth()) {
         header('Location: /user/');
     } else {
         if (isset($_POST['login'])) {
             $login = $_POST['login'];
             $email = $_POST['email'];
             $pass = $_POST['password'];
             $repass = $_POST['repassword'];
             if (isset($login) && !empty($login) && (isset($email) && !empty($email)) && (isset($pass) && !empty($pass)) && (isset($repass) && !empty($repass))) {
                 if ($pass === $repass) {
                     $user = new User();
                     $res = $user->user_register(array('login' => $login, 'email' => $email, 'pass' => $pass));
                     if ($res == 'OK') {
                         header('Location: /user/');
                     } else {
                         $this->render('register', array('error' => $res));
                     }
                 } else {
                     $error = 'Пароли не совпадают';
                     $this->render('register', array('error' => $error));
                 }
             } else {
                 $error = 'Все поля необходимы для заполнения!';
                 $this->render('register', array('error' => $error));
             }
         } else {
             $this->render('register');
         }
     }
 }
Example #12
Show file File: enter.php Project: WinGood/24karcher
0
 function __construct()
 {
     $this->fPass = new Models_Forgotpass();
     if (URL::getQueryParametr('logout')) {
         User::logout();
     }
     if (User::isAuth()) {
         MG::redirect('/personal');
     }
     if (isset($_POST['registration'])) {
         // Если данные введены верно.
         if (!$this->unValidForm()) {
             USER::add($this->userData);
             $message = '<span class="succes-reg">Вы успешно зарегистрировались! Для активации пользователя Вам необходимо перейти по ссылке высланной на Ваш электронный адрес <strong>' . $this->userData['email'] . '</strong></span>';
             $form = false;
             // Рассылаем письма со ссылкой для подтверждения регистрации.
             $this->_sendActivationMail($this->userData['email']);
             unset($_POST);
         } else {
             $error = $this->error;
             $form = true;
         }
     } else {
         // Если пользователь не авторизован.
         if (!User::isAuth() && (isset($_POST['email']) || isset($_POST['pass']))) {
             if (!User::auth(URL::get('email'), URL::get('pass'))) {
                 $error = '<span class="msgError">' . 'Неправильная пара email-пароль! Авторизоваться не удалось.' . '</span>';
             } else {
                 $this->successfulLogon();
             }
         }
     }
     $data = array('meta_title' => 'Авторизация', 'msgError' => $error, 'message' => $message, 'meta_keywords' => !empty($model->currentCategory['meta_keywords']) ? $model->currentCategory['meta_keywords'] : "Авторизация,вход, войти в личный кабинет", 'meta_desc' => !empty($model->currentCategory['meta_desc']) ? $model->currentCategory['meta_desc'] : "Авторизуйтесь на сайте и вы получите дополнительные возможности, недоступные для обычных пользователей.");
     $this->data = $data;
 }
Example #13
Show file File: UserController.php Project: Constantinehub/first_project
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //Валидация полей
         if (User::checkEmail($email)) {
             $errors[] = 'Ошибка, Не верный email';
         }
         if (User::checkPassword($password)) {
             $errors[] = 'Ошибка, пароль должен состоять минимум из 6 символов';
         }
         //Проверяем существует ли пользователь
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             //Если данные не верные - показываем ошибку
             $errors[] = 'Ошибка входа на сайт Введенные данные неправильные!';
         } else {
             //Если данные правильные, запоминаем пользователя (сессия)
             User::auth($userId);
             //Перенаправляем пользователя в закрытую часть (cabinet)
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #14
Show file File: UserController.php Project: dmitry-politov/e-shopper
0
 /**
  * Action для страницы "Вход на сайт"
  */
 public function actionLogin()
 {
     // Переменные для формы
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $email = $_POST['email'];
         $password = $_POST['password'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkEmail($email)) {
             $errors[] = 'Неверная форма email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль короче 6 символов';
         }
         // Проверяем, существует ли пользователь
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             // Если данные неправильные - показываем ошибку
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             //Если данные правильные  - запоминаем пользователя (сессия)
             User::auth($userId);
             //Перенаправляем пользователя в закрытую часть - кабинет
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #15
Show file File: UserController.php Project: xcorn/someblog
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //Валидация
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправельный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         //Проверка пользователя
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             User::auth($userId);
             //redirect
             header("Location: /");
         }
     }
     require_once ROOT . '/views/user/login.php';
 }
Example #16
Show file File: Controller.php Project: KGB-Steam/test
0
 function __construct()
 {
     $this->tplPath = APP . 'views/';
     $this->tplControllerPath = APP . 'views/' . strtolower(str_replace('Controller', '', get_called_class())) . '/';
     if (User::auth()) {
         $this->layout = 'base';
     } else {
         $this->layout = 'simple';
     }
 }
Example #17
Show file File: GameController.php Project: KGB-Steam/test
0
 function actionIndex()
 {
     if (!User::auth()) {
         header('Location: /user/login/');
     } else {
         $game = new Game();
         $model = $game->get_all_questions();
         $this->render('index', array('model' => $model));
     }
 }
Example #18
Show file File: Submitlogin.php Project: rx-projects/comicasa
0
 public function invokeHandler(Smarty $viewModel, Header $header, User $user, $uname, $upass)
 {
     $header->title('PayPic');
     $header->import('jqgeeks/bootstrap_css', 'google_login');
     $viewModel->assign("pname", "@RTPic");
     if ($user->auth($uname, $upass)) {
         include_once HANDLER_PATH . "/Images.php";
         return Images::showlatest($viewModel);
     } else {
         return "login";
     }
 }
Example #19
Show file File: auth.php Project: openweb-tech/hotbackup
0
 public function execute()
 {
     sleep(1);
     $login = htmlspecialchars($_POST['login'], ENT_QUOTES);
     $password = $_POST['password'];
     $user = new User(0, __userdb);
     $user->auth($login, $password);
     if ($user->isAuthorized()) {
         $this->redirect('');
     } else {
         $this->redirect('?r=auth&error=1');
     }
 }
Example #20
Show file File: PageAuth.php Project: AlexOrfen/Schedule
0
 public function doSignIn()
 {
     $email = Data::get('email');
     $password = Data::get('password');
     $a = (object) array('success' => false, 'message' => '');
     if (User::auth($email, $password)) {
         $a->message = 'Вы успешно авторизовались';
         $a->success = true;
     } else {
         $a->message = 'Ошибка при авторизации';
     }
     return $a;
 }
Example #21
Show file File: enter.php Project: nellka/mebel
0
 function __construct()
 {
     // Разлогиниваем пользователя.
     if (URL::getQueryParametr('logout')) {
         User::logout();
     }
     // Пользователь уже авторизован, отправляем его в личный кабинет.
     if (User::isAuth()) {
         MG::redirect('/personal');
     }
     $data = array('meta_title' => 'Авторизация', 'meta_keywords' => !empty($model->currentCategory['meta_keywords']) ? $model->currentCategory['meta_keywords'] : "Авторизация,вход, войти в личный кабинет", 'meta_desc' => !empty($model->currentCategory['meta_desc']) ? $model->currentCategory['meta_desc'] : "Авторизуйтесь на сайте и вы получите дополнительные возможности, недоступные для обычных пользователей.");
     // Если загрузка произведена по ссылке для отмены блокировки авторизации.
     if (URL::getQueryParametr('unlock')) {
         if (URL::getQueryParametr('unlock') == $_SESSION['unlockCode']) {
             unset($_SESSION['loginAttempt']);
             unset($_SESSION['blockTimeStart']);
             unset($_SESSION['unlockCode']);
         }
     }
     // Если пользователь не авторизован, проверяется  правильность ввода данных и количество неудачных попыток.
     if (!User::isAuth() && (isset($_POST['email']) || isset($_POST['pass']))) {
         $loginAttempt = (int) LOGIN_ATTEMPT ? LOGIN_ATTEMPT : 5;
         $capcha = isset($_POST['capcha']) ? $_POST['capcha'] : false;
         unset($_POST['capcha']);
         if (!User::auth(URL::get('email'), URL::get('pass'), $capcha)) {
             if ($_SESSION['loginAttempt'] < 2) {
                 $data['msgError'] = '<span class="msgError">' . 'Неправильная пара email-пароль! Авторизоваться не удалось.' . '</span>';
             } elseif ($_SESSION['loginAttempt'] < $loginAttempt) {
                 $data['msgError'] = '<span class="msgError">' . 'Неправильно введен код с картинки! Авторизоваться не удалось.' . ' Количество оставшихся попыток - ' . ($loginAttempt - $_SESSION['loginAttempt']) . '</span>';
                 $data['checkCapcha'] = '<div class="checkCapcha">
         <img style="margin-top: 5px; border: 1px solid gray; background: url("' . PATH_TEMPLATE . '/images/cap.png")" src = "captcha.html" width="140" height="36">
         <div>Введите текст с картинки:<span class="red-star">*</span> </div>
         <input type="text" name="capcha" class="captcha">';
             } else {
                 if (!isset($_SESSION['blockTimeStart'])) {
                     // Начало отсчета  времени блокировки на 15 мин.
                     $_SESSION['blockTimeStart'] = time();
                     $_SESSION['unlockCode'] = md5('mg' . time());
                     $this->sendUnlockMail($_SESSION['unlockCode']);
                 }
                 $data['msgError'] = '<span class="msgError">' . 'В целях безопасности возможность авторизации ' . 'заблокирована на 15 мин. Отсчет времени от ' . date("H:i:s", $_SESSION['blockTimeStart']) . '</span>';
             }
         } else {
             $this->successfulLogon();
         }
     }
     $this->data = $data;
 }
Example #22
Show file File: PageAuth.php Project: lobovmaxim/Schedule-1
0
 public function ajaxSignIn()
 {
     $user = new StdClass();
     $fields = array('name' => Data::STR, 'password' => Data::STR);
     foreach ($fields as $field => $dataType) {
         $user->{$field} = Data::get($field, '', $dataType);
     }
     $a = (object) array('success' => false, 'message' => '0');
     if (User::auth($user)) {
         $a->message = 'Вы успешно авторизовались';
         $a->success = true;
     } else {
         $a->message = 'Ошибка при авторизации';
     }
     return $a;
 }
Example #23
Show file File: Auth.class.php Project: Yogurt933/Made-Easy
0
 function loged()
 {
     $login = false;
     $password = false;
     $auth = Request::cookie('auth') ? Request::cookie('auth') : false;
     if (!$auth) {
         return false;
     }
     $login = $auth['login'];
     $password = $auth['password'];
     if ($login && $password) {
         $user = new User();
         return $user->auth($login, $password);
     }
     return false;
 }
Example #24
Show file File: AetherModuleAuthed.php Project: nervetattoo/rutetid
0
 /**
  * Attempt to authenticate the user and store session info
  *
  * @return bool
  * @param array $data
  */
 protected function logIn($data)
 {
     $username = $data['username'];
     $password = $data['password'];
     $user = User::byUsername($username);
     if ($user) {
         if (User::auth($user, $password)) {
             $_SESSION['userId'] = $user['_id'];
             return 1;
         } else {
             unset($_SESSION['userId']);
             return 0;
         }
     } else {
         return -1;
     }
 }
Example #25
Show file File: IndexController.php Project: nkammah/Crash-Analytics
0
 public function indexAjax()
 {
     $input = Input::requireParams('username', 'pass', 'r');
     if (($user = User::auth($input->username, $input->pass)) !== false) {
         $sessionData = $user->getData();
         $sessionData['previous_login'] = $user->last_login;
         $user->updateLoginStats();
         $sessionData['last_login'] = gmdate('Y-m-d H:i:s');
         Cookie::set('username', $input->username, time() + 3600 * 24 * 30);
         Log::info("User {$input->username} logged in with " . Request::userAgent());
         // some stats
         $sessionData['stats'] = array('new_stack_traces' => \Stack\Trace::getNewCount($sessionData['previous_login']));
         Session::set('user', $sessionData);
         return BootstrapUI::formResponse()->redirect(base64_decode($input->r));
     } else {
         Log::info("Invalid auth for '{$input->username}' with '{$input->pass}'");
         return BootstrapUI::formResponse()->failed('Wrong username or password');
     }
 }
Example #26
Show file File: usercontroller.php Project: rezaprima/icms
0
 public function login()
 {
     View::$title = 'Login';
     $user = new User();
     if (isset($_POST['submit'])) {
         if ($user->auth($_POST['uid'], $_POST['pwd'])) {
             if (isset($_SESSION['LOGIN_REFERER'])) {
                 $ref = $_SESSION['LOGIN_REFERER'];
                 unset($_SESSION['LOGIN_REFERER']);
                 return $ref;
             }
             return '/';
         }
     } else {
         if (!isset($_SESSION['LOGIN_REFERER']) && isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'user') === FALSE) {
             $_SESSION['LOGIN_REFERER'] = $_SERVER['HTTP_REFERER'];
         }
     }
     return array();
 }
Example #27
Show file File: UserController.php Project: schulz-brander/vk.loc.mvc
0
 public function login()
 {
     $authUser = new User();
     $authUser->auth($_POST);
     //метод авторизации с параметром пост
     $data = $authUser->showData;
     //через него получаем данные с базы - мыло, пароль и др.
     if (!empty($_POST) && $_POST['eMail'] == $data['e_mail'] && $_POST['password'] == $data['pass']) {
         $_SESSION['id'] = $data['id'];
         $_SESSION['userName'] = $data['user_name'];
         $this->renderView('user/login', array('result' => $authUser->authResult));
         return;
     }
     if (!empty($_POST) && $_POST['eMail'] != $data['e_mail']) {
         $this->renderView('user/login', array('result' => 'Неверно введено имя или пароль!'));
         return;
     }
     if (empty($_POST) && !empty($_SESSION['id']) && !empty($_SESSION['userName'])) {
         $this->renderView('user/login', array('result' => $authUser->authResult));
     }
     $this->renderView('user/login');
 }
Example #28
Show file File: user.php Project: jbaicoianu/elation
0
 public function controller_auth($args)
 {
     $vars = array();
     $vars["userid"] = any($args["userid"], "");
     $vars["credentials"] = any($args["credentials"], "");
     $vars["success"] = false;
     if (!empty($vars["userid"]) && !empty($vars["credentials"])) {
         $vars["user"] = User::auth("default", $vars["userid"], $vars["credentials"]);
         if (!empty($vars["user"])) {
             $vars["success"] = true;
             $vars["newuser"] = false;
         } else {
             if (!empty($args["create"])) {
                 $vars["user"] = User::create("default", $vars["userid"], $vars["credentials"]);
                 if (!empty($vars["user"])) {
                     $vars["success"] = true;
                     $vars["newuser"] = true;
                 }
             }
         }
     }
     return $this->GetComponentResponse("./auth.tpl", $vars);
 }
Example #29
Show file File: login.php Project: bensonby/csc2720
0
<?php

include 'inc.php';
//process login request..
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $user_id = User::auth($_POST["username"], $_POST["password"]);
    if ($user_id) {
        $_SESSION['user_id'] = $user_id;
        $user = new User($user_id);
        //to assign a new cart to a user if there are no carts
        if (!Order::get_orderid($user_id)) {
            $order = new Order();
            $user->assign_order($order);
            $order->save();
        }
        header("Location: index.php");
        exit;
    } else {
        set_msg("Login Failed");
    }
}
include 'header.php';
include 'menu.php';
?>

<div id="content">
<div id="sign-in-block">
  <form method="post" action="login.php">
    <p>
      <label for="username">Username</label>
      <input type="text" name="username" size="10" />
Example #30
Show file File: core.php Project: hrn4n/argon
0
include "settings/settings.php";
$pdo_link = new PDO("mysql:dbname={$db_name};host={$db_host}", $db_user, $db_password);
function autoloader($class_name)
{
    include "classes/" . strtolower($class_name) . ".class.php";
}
spl_autoload_register('autoloader');
/**
*	Attempt to load a user
*/
$SESSION_STARTED = false;
if (isset($_SERVER["HTTP_X_AUTH_KEY"]) && ($auth_key_header = explode(":", $_SERVER["HTTP_X_AUTH_KEY"])) && count($auth_key_header) == 2) {
    list($sess_username, $sess_password) = $auth_key_header;
    $CURRENT_USER = new User($pdo_link);
    $CURRENT_USER->username = $sess_username;
    $CURRENT_USER->password = $sess_password;
    if ($CURRENT_USER->auth()) {
        $SESSION_STARTED = true;
    }
}
if (isset($_SERVER["HTTP_X_SESSION_TOKEN"])) {
    if (count($AR_SESSION_PAIR = explode(":", $_SERVER["HTTP_X_SESSION_TOKEN"])) == 2) {
        $AR_SESSION = new Session($pdo_link);
        list($sess_username, $token) = $AR_SESSION_PAIR;
        $AR_SESSION->token = $token;
        if ($AR_SESSION->authorize($sess_username)) {
            $CURRENT_USER = $AR_SESSION->user;
            $SESSION_STARTED = true;
        }
    }
}