Beispiel #1
0
function login() {
  try {
    $A = new Auth();
  } catch(Exception $e) {
    die($e->getMessage());
  }


  if($_POST['password']) {
    $P = new Password();

    if(!$P->isValid($_POST['password'])) {
      $pass_incorrect = true;
    } else {
      $set_cookie = true;

      $cookieval = set_auth_cookie();

      try {
        $A->create($cookieval);
      } catch(Exception $e) {
        die($e->getMessage());
      }
    }
  } else {
    if(isset($_COOKIE['auth']) && $A->isValid($_COOKIE['auth']))
      $already_set = true;
  }
  ?>

  <!DOCTYPE html>
  <html>
  <head><title>set scraps password</title></head>
  <body>

  <?php if($pass_incorrect): ?>

    <p>The password entered does not match the current password.</p>

  <?php elseif($set_cookie): ?>

    <p>Y'all should be logged in now.</p>

  <?php elseif($already_set): ?>

    <p>Y'all is already logged in.</p>

  <?php else: ?>

    <form method="post">
    <input name="password" type="password" placeholder="Password?" \>
    <input type="submit" value="Login" />
    </form>

    </body>
    </html>

  <?php endif;
}
function token()
{
    global $instDir, $objMessages, $entryMessage;
    // Get the userid
    include_once $instDir . "lib/password.php";
    $password = new Password();
    $token = $_GET['t'];
    if ($password->tokenExists($token)) {
        // Only go on when the token is not too old. If the token is too old, remove the token.
        if ($password->isValid($token)) {
            // Go to the correct
            echo "<div id=\"main\">";
            // TODO: Add form to change the password.
            // TODO: Add scripts to change the password.
            print "TEST: " . $userid;
            echo "</div>";
        } else {
            // TODO: Change
            print "<br/>TOKEN IS NOT VALID ANYMORE!";
        }
    } else {
        // TODO: Change message
        $entryMessage = "TOKEN DOES NOT EXIST!";
        $_GET['indexAction'] = 'main';
        // TODO: Return the index page
        return;
    }
    if (sizeof($userid) > 0) {
        // Clear the request
        $password->removeToken($token);
        // Send a mail that the request was canceled.
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        $subject = LangCancelRequestNewPasswordSubject;
        $message = LangCancelRequestNewPassword1 . $ip;
        $message .= LangCancelRequestNewPassword2;
        $objMessages->sendEmail($subject, $message, $userid);
        // Go to the DeepskyLog page and show 'Your password change request was canceled'
        $entryMessage = LangCancelRequestNewPasswordSubject . ".";
    }
}
Beispiel #3
0
 public function login()
 {
     if ($_POST) {
         $pass = new Password();
         $filter = new Validations();
         $auth = new Authorization();
         $username = $filter->sanitizeText($_POST["username"]);
         $password = $filter->sanitizeText($_POST["password"]);
         $options['conditions'] = " username = '******'";
         $user = $this->User->find("users", "first", $options);
         if ($pass->isValid($password, $user['password'])) {
             $auth->login($user);
             $this->redirect(array("controller" => "users", "action" => "index"));
         } else {
             echo "Usuario Invalido";
         }
     }
 }
 public function login()
 {
     if ($_POST) {
         $pass = new Password();
         $filter = new Validations();
         $aut = new Authorization();
         $username = $filter->sanitizeText($_POST['username']);
         $password = $filter->sanitizeText($_POST['password']);
         $options['conditions'] = "username = '******'";
         $usuario = $this->db->find('usuarios', 'first', $options);
         if ($pass->isValid($password, $usuario['password'])) {
             $aut->login($usuario);
             $this->redirect(array('controller' => 'tareas'));
         } else {
             echo "Usuario Invalido";
         }
     }
     $this->_view->renderizar('login');
 }
 public function login()
 {
     if ($_POST) {
         $pass = new Password();
         # code...
         $filter = new Validations();
         $auth = new Authorization();
         $username = $filter->sanitizeText($_POST['username']);
         $password = $filter->sanitizeText($_POST['password']);
         $options = array('conditions' => "username='******'");
         $usuario = $this->db->find('usuarios', 'first', $options);
         if ($pass->isValid($password, $usuario['password'])) {
             $auth->login($usuario);
             $this->redirect(array('controller' => 'usuarios', 'action' => 'escritorio'));
         } else {
             echo "<script type='text/javascript'>\n\t\t     alert('usuario no valido');\n\t\t    </script>";
         }
     }
     $this->_view->renderizar('login', 'login');
 }
 /**
  *Metodo de los usuarios cuando inicien en la aplicacion
  */
 public function login()
 {
     if ($_POST) {
         $pass = new Password();
         $filter = new Validations();
         //sanear lo que se reciba en el formaulario
         $auth = new Authorization();
         $username = $filter->sanitizeText($_POST["username"]);
         //sanea cajas
         $password = $filter->sanitizeText($_POST["password"]);
         $options = array("conditions" => "username = '******'");
         $usuario = $this->find("usuarios", "first", $options);
         if ($pass->isValid($password, $usuario["password"])) {
             $auth->login($usuario);
             $this->redirect(array("controller" => "tareas"));
         } else {
             echo "Usuario invalido";
         }
     }
     $this->_view->renderizar("login");
 }
function change_password()
{
    global $instDir, $entryMessage, $baseURL;
    include_once $instDir . "lib/password.php";
    $password = new Password();
    $token = $_GET['t'];
    // Move this to control, only setting the password to this file.
    // Only show the change password form when the token is known
    if ($password->tokenExists($token)) {
        $userid = $password->getUserId($token);
        // Check if the token is not too old. If the token is too old, remove the token.
        if ($password->isValid($token)) {
            // Add form to change the password.
            echo "<div id=\"main\">\n              <form action=\"" . $baseURL . "index.php?indexAction=changepasswordToken\" method=\"post\">\n              " . LangNewPassword . "\n              <input type=\"hidden\" name=\"userid\" value=\"" . $userid . "\" />\n              <input type=\"hidden\" name=\"token\" value=\"" . $token . "\" />\n              <input type=\"password\" name=\"newPassword\" class=\"strength\" required>" . LangChangeAccountField6 . "\n              <input type=\"password\" name=\"confirmPassword\" class=\"strength\" required data-show-meter=\"false\">\n              <br />\n              <input class=\"btn btn-danger\" type=\"submit\" name=\"changePasswordToken\" value=\"" . LangChangePassword . "\" />";
            echo "</div>";
        } else {
            echo "<meta http-equiv=\"refresh\" content=\"0; url=/index.php\" />";
        }
    } else {
        echo "<meta http-equiv=\"refresh\" content=\"0; url=/index.php\" />";
    }
}
 public function login()
 {
     /**
      * function that allows the user to login
      * @param password $pass password of the user
      * @param $filter to validate that the password is correct
      * @param $auth to authorize the entrance to de system
      * 
      * @return void
      */
     if ($_POST) {
         $pass = new Password();
         $filter = new Validations();
         $auth = new Authorization();
         $username = $filter->sanitizeText($_POST['username']);
         $password = $filter->sanitizeText($_POST['password']);
         $options = array('conditions' => "username = '******'");
         $usuario = $this->db->find('usuarios', 'first', $options);
         if ($pass->isValid($password, $usuario['password'])) {
             $auth->login($usuario);
             $this->redirect(array('controller' => 'tareas'));
         } else {
             echo "Usuario no valido";
         }
     }
     $this->_view->renderizar('login');
 }
Beispiel #9
0
  function POST($matches) {
    $P = new Password();

    if(!$P->isValid($_POST['password'])) {
      $this->layout_vars = array(
        'content' => "The password you entered is incorrect.");
    } else {
      $A = new Article();
      if($A->deleteArticle($matches[1])) {
        $this->layout_vars = array(
          'content' => "Congratulations, you delete a post. Everyone is so proud.");
      } else {
        $this->layout_vars = array(
	  'content' => "Couldn't delete post. Fuuuuuu-");
      }
    }
  }