Skip to content

Instantly share code, notes, and snippets.

@danjesus
Created August 22, 2011 15:12
Show Gist options
  • Save danjesus/1162617 to your computer and use it in GitHub Desktop.
Save danjesus/1162617 to your computer and use it in GitHub Desktop.
Diesel Framework 1.0 - Add login to controller
public function login() {
if ($_SESSION['csrfToken'] == $_POST['isValid']) {
$username = clear($_POST['username']);
$password = User::generateHash($_POST['password']);
$user = LDB::GetSingleByProperty("users", array('username' => $username));
if (!$user) {
redirect("admin/dashboard/index/login_failed");
} else if ($user['password'] !== $password) {
redirect("admin/dashboard/index/login_failed");
} else {
Session::create($user['id']);
redirect("admin/dashboard");
}
} else {
redirect("admin/dashboard/index/login_failed");
}
}
public function logout() {
Session::destroy();
redirect("home");
}
public function generateUserHash($pass) {
die("<textarea>" . User::generateHash($pass) . "</textarea>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment