login() публичный статический Метод

Login process (for DEFAULT user accounts).
public static login ( $user_name, $user_password, $set_remember_me_cookie = null ) : boolean
$user_name string The user's name
$user_password string The user's password
$set_remember_me_cookie mixed Marker for usage of remember-me cookie feature
Результат boolean success state
Пример #1
0
 /**
  * The login action, when you do login/login
  */
 public function login()
 {
     // check if csrf token is valid
     if (!Csrf::isTokenValid()) {
         LoginModel::logout();
         Redirect::home();
         exit;
     }
     // perform the login method, put result (true or false) into $login_successful
     $login_successful = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
     // check login status: if true, then redirect user to user/index, if false, then to login form again
     if ($login_successful) {
         if (Request::post('redirect')) {
             Redirect::toPreviousViewedPageAfterLogin(ltrim(urldecode(Request::post('redirect')), '/'));
         } else {
             Redirect::to('user/index');
         }
     } else {
         if (Request::post('redirect')) {
             Redirect::to('login?redirect=' . ltrim(urlencode(Request::post('redirect')), '/'));
         } else {
             Redirect::to('login/index');
         }
     }
 }
Пример #2
0
 /**
  * The login action, when you do login/login
  */
 public function login()
 {
     // perform the login method, put result (true or false) into $login_successful
     $login_successful = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
     // check login status: if true, then redirect user login/showProfile, if false, then to login form again
     if ($login_successful) {
         Redirect::to('login/showProfile');
     } else {
         Redirect::to('login/index');
     }
 }
 public static function login($data)
 {
     if (isset($data['username']) && empty($data['username'])) {
         return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Username is required'));
     }
     if (isset($data['password']) && empty($data['password'])) {
         return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Password is required'));
     } else {
         LoginModel::login($data);
     }
 }
Пример #4
0
 public function indexAction()
 {
     if ($this->_request->isPost()) {
         $auth = new LoginModel();
         $auth_res = $auth->login($this->_request->getParam('username'), $this->_request->getParam('password'));
         $this->view->yesno = $auth_res ? "yes" : "no";
         $this->_redirect("/");
         //$authNamespace = new Zend_Session_Namespace('Zend_Auth');
         //$this->view->username=$authNamespace->user;
     }
 }
 public function login()
 {
     if (!Csrf::isTokenValid()) {
         self::logout();
     }
     $success = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
     // check login status: if true, then redirect user login/showProfile, if false, then to login form again
     if ($success) {
         if (Request::post('redirect')) {
             Redirect::to(ltrim(urldecode(Request::post('redirect')), '/'));
         } else {
             Redirect::to('login/showProfile');
         }
     } else {
         Redirect::to('login/index');
     }
 }
Пример #6
0
 /**
  * The login action, when you do login/login
  */
 public function login()
 {
     // check if csrf token is valid
     if (!Csrf::isTokenValid()) {
         self::logout();
     }
     // perform the login method, put result (true or false) into $login_successful
     $login_successful = LoginModel::login(Request::post('user_name'), Request::post('user_password'), Request::post('set_remember_me_cookie'));
     // check login status: if true, then redirect user login/showProfile, if false, then to login form again
     if ($login_successful) {
         if (Request::post('redirect')) {
             Redirect::to(ltrim(urldecode(Request::post('redirect')), '/'));
         } else {
             Redirect::to('login/showProfile');
         }
     } else {
         Redirect::to('login/index');
     }
 }
Пример #7
0
 public function ajaxLogin()
 {
     if (!Csrf::isTokenValid()) {
         LoginModel::logout();
         echo 'NT';
         return;
     }
     openssl_private_decrypt(base64_decode(Request::get_post('password')), $password, Session::get('RSA_private'));
     $login_successful = LoginModel::login(Request::get_post('username'), $password, Request::get_post('remember_me'));
     if ($login_successful) {
         if ($redirect = Request::get_post('redirect')) {
             echo ltrim(urldecode($redirect), '/');
         } else {
             echo Config::get('URL') . '/account';
         }
     } else {
         echo 'N';
     }
 }
Пример #8
0
 public function unlock()
 {
     LoginModel::login(Request::post('user_name'), Request::post('user_password'));
     LockModel::unlock();
 }
Пример #9
0
 /**
  * @function logoutTimeoutTutor
  * @public
  * @static
  * @returns NONE
  * @desc NONE
  * @param NONE
  * @example NONE
  */
 public static function logoutTimeoutTutor()
 {
     LoginModel::logout();
     $login_successful = LoginModel::login('student', 'system', '');
 }
Пример #10
0
 public function createAction()
 {
     if (empty($_POST['pseudo'])) {
         $erreur['pseudo'] = 'Veuillez entrer un pseudo';
     } else {
         if (strlen($_POST['pseudo']) < 7) {
             $erreur['pseudo'] = 'Votre pseudo est trop court';
         }
     }
     if (empty($_POST['firstname'])) {
         $erreur['firstname'] = 'Veuillez entrer un prenom';
     }
     if (empty($_POST['lastname'])) {
         $erreur['lastname'] = 'Veuillez entrer un nom de famille';
     }
     if (empty($_POST['password']) || empty($_POST['password2']) || strlen($_POST['password']) < 6) {
         $erreur['password'] = '******'au moins 6 caracteres et le confimer';
     } else {
         if ($_POST['password'] != $_POST['password2']) {
             $erreur['password'] = '******';
         }
     }
     if (!empty($erreur)) {
         $erreur['error'] = 'champs';
         return json_encode($erreur);
     }
     $result = LoginModel::login($this->pdo, $_POST['pseudo']);
     if ($result != false) {
         $erreur['error'] = 'pris';
         return json_encode($erreur);
     }
     UserModel::createUser($this->pdo, $_POST['pseudo'], $_POST['firstname'], $_POST['lastname'], sha1($_POST['password']));
     return json_encode(['success' => 'created']);
 }
Пример #11
0
<?php

require_once __DIR__ . '/classes/Tools.php';
Tools::startSession();
$success = false;
$loginEmail = '';
if (!empty($_POST)) {
    $success = LoginModel::login($_POST['login_email'], $_POST['login_pass']);
    $loginEmail = trim(htmlspecialchars($_POST['login_email']));
} else {
    $success = SessionWrapper::userIsLoggedIn();
}
if ($success) {
    header("Location: " . Tools::getBaseUrl() . '/');
    exit;
}
$headerMeta = array('title' => 'Iniciar sesión');
$headerResources = '
  <link href="' . Tools::getBaseUrl() . '/css/style-login.css" rel="stylesheet" />';
require_once 'header.php';
?>

    <div class="tittle_categoria"><h1>Iniciar sesión</h1></div>

    <main><form id="login_form" method="post">
      <div class="text-left">
        Email
        <input type="email" name="login_email" id="login_email" value="<?php 
echo $loginEmail;
?>
" />