Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * login
- *
- * Handles the login of an admin, or writer as they are sometimes referred to.
- *
- * @static
- * @return void
- */
- public static function login()
- {
- $validator = \Validator::make(\Input::get(), array(
- 'name' => array('required'),
- 'password' => array('required')
- ), array(
- 'name_required' => 'Name is required.',
- 'password_required' => 'Password is required.'
- ));
- if(!$validator->valid()) return $validator->errors;
- $name = $password = null; extract(\Input::get());
- $user = static::where('name', '=', $name)->first();
- if(is_null($user))
- {
- $validator->errors->add('name', 'Name does not exist.');
- return $validator->errors;
- }
- elseif(sha1($user->password_salt . $password) != $user->password)
- {
- $validator->errors->add('password', 'Password incorrect.');
- return $validator->errors;
- }
- return $user;
- }
Add Comment
Please, Sign In to add comment