Last active
January 22, 2017 12:10
-
-
Save bradynpoulsen/4a418559c6543de984a7e5e17cd7d8c4 to your computer and use it in GitHub Desktop.
Revisions
-
bradynpoulsen revised this gist
Jan 22, 2017 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
bradynpoulsen created this gist
Jan 22, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ <?php $providedEmail = $_SERVER['PHP_AUTH_USER']; $providedPassword = $_SERVER['PHP_AUTH_PW']; $user = User::find_by_email($providedEmail); if ($user) { if (password_verify($providedPassword, $user->password_digest)) { session_start(); $_SESSION['user_id'] = $user->id; header('HTTP/1.1 200 Ok'); header('Location: https://example.com/my-account'); echo 'You have successfully logged in!'; exit(); } } header('HTTP/1.1 403 Forbidden'); echo 'You provided an invalid email/password'; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <?php $user = new User; $user->email = 'foo@example.com'; $user->password_digest = password_hash('mypassword', PASSWORD_DEFAULT); $user->save();