Guest User

Untitled

a guest
Nov 19th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. /**
  3. * login
  4. *
  5. * Handles the login of an admin, or writer as they are sometimes referred to.
  6. *
  7. * @static
  8. * @return void
  9. */
  10. public static function login()
  11. {
  12. $validator = \Validator::make(\Input::get(), array(
  13. 'name' => array('required'),
  14. 'password' => array('required')
  15. ), array(
  16. 'name_required' => 'Name is required.',
  17. 'password_required' => 'Password is required.'
  18. ));
  19.  
  20. if(!$validator->valid()) return $validator->errors;
  21.  
  22. $name = $password = null; extract(\Input::get());
  23.  
  24. $user = static::where('name', '=', $name)->first();
  25. if(is_null($user))
  26. {
  27. $validator->errors->add('name', 'Name does not exist.');
  28. return $validator->errors;
  29. }
  30. elseif(sha1($user->password_salt . $password) != $user->password)
  31. {
  32. $validator->errors->add('password', 'Password incorrect.');
  33. return $validator->errors;
  34. }
  35.  
  36. return $user;
  37. }
Add Comment
Please, Sign In to add comment