/** * Authenticate a user based on the request information. * * Called only by Auth->login() to validate the User. The returned User * array must contain the authentication token that was generated so it * can be passed back to the client for future user. * * There are also two side effects: * 1. The password hash stored in the DB for the User is updated from * SHA1 to Blowfish (if necessary). * 2. The last_login_at and token fields are written back into the * User model record. * * @param CakeRequest $request Request to get authentication information from. * @param CakeResponse $response A response object that can have headers added. * @return mixed Either false on failure, or an array of user data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { $userModel = $this->settings['userModel']; list(, $model) = pluginSplit($userModel); $alias = $this->UserModel->alias; $fields = $this->settings['fields']; // Add a surrounding [User] array, if not present. if (isset($request->data[$fields['username']])) { $request->data = array($alias => $request->data); } // Check the fields. if (!$this->checkFields($request, $alias)) { return false; } // Call the login method. $user = $this->UserModel->login($request->data[$alias][$fields['username']], $request->data[$alias][$fields['password']]); if (!$user) { return false; } return $user; }
</tr> <tr> <td> <font>Palabra Clave</font> </td> <td> <input type="password" name="usuario_password" id="usuario_password" value="" maxlength="50" size="20"> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="Conexión" style="float: right"> </td> </tr> </table> </div> </form> <?php include "./conexion.php"; $db = new MySQL(); if (isset($usuario_login) && isset($usuario_password)) { include "./model.php"; $model = new Model(); $_SESSION['login'] = $model->login($usuario_login, $usuario_password); if ($_SESSION['login'] == true) { echo "<script>window.location = './index.php'</script>"; } } ?> </body> </html>
//Redirect if logged in session_start(); header("Location:" . "http://" . $_SERVER['SERVER_NAME'] . "/shop"); } ?> <?php $model = new Model(); flash("notice"); ?> <?php if (isset($_POST['admin_login_submit'])) { $username = htmlspecialchars($_POST['admin_login_username']); $password = htmlspecialchars($_POST['admin_login_password']); if ($model->login($username, $password)) { flash("notice", "Login succesfuly as " . $username); header("Location:" . "http://" . $_SERVER['SERVER_NAME'] . "/shop"); } else { flash("notice", "Login failed", "error"); header("Location: " . $_SERVER['REQUEST_URI']); } } ?> <h3>Admin Login</h3> <form action="" method="post" style="line-height: 3em"> <input type="text" name="admin_login_username" placeholder="Username"><br> <input type="password" name="admin_login_password" placeholder="Password"><br> <input type="submit" name="admin_login_submit" value="Log in"> </form>
<?php session_start(); require_once 'config.php'; require_once 'Model.php'; $login = new Model(); $res = $login->login($_POST); print_r($res);