Permalink
Cannot retrieve contributors at this time
cse4707-secure-messaging/public/login.php
Go to file<?php | |
defined('APP_DIR') or define('APP_DIR', __DIR__ . '/../app/'); | |
include_once(APP_DIR . 'controller/UserController.php'); | |
include_once(APP_DIR . 'include/http.php'); | |
$attempts = User::get(Http::post_params()['username'])->login_attempts; | |
if ($attempts >= 8) { | |
Http::redirect('index.php', ['error' => '2']); | |
} | |
$user = UserController::authenticate(Http::post_params()); | |
if (!$user) { | |
Http::redirect('index.php', ['error' => '1']); | |
} | |
setcookie(Config::cookie_name, $user->token()); | |
if ($user->access == 'user') { | |
Http::redirect('user.php'); | |
} else if ($user->access == 'admin') { | |
Http::redirect('admin.php'); | |
} | |
?> |