Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function hash_password($password) {
- return hash('sha256', $password);
- }
- function check_password($hash, $password) {
- return $hash === hash_password($password);
- }
- function authenticate($email, $password) {
- $user = R::findOne('user', ' email=? ', array($email));
- if ($user === null) return false;
- return check_password($user->encrypted_password, $passwod);
- }
- function save_user($name, $email, $password) {
- $user = R::dispense('user');
- $user->name = $name;
- $user->email = $email;
- $user->encrypted_password = hash_password($password);
- $id = $::store($user);
- if ($id === null) return null;
- return $user;
- }
Add Comment
Please, Sign In to add comment