Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AuthController extends Auth
- {
- public function loginUser()
- {
- $username = Request::get('username');
- $password = Request::get('password');
- $error = false;
- $passwordhash = password = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);
- if ( password_verify ($password , $passwordhash ))
- {
- $userdata = array(
- 'username' => $username,
- 'password' => $password
- );
- $error = true;
- $user = array();
- if (Auth::attemp($userdata)) {
- $error = false;
- $user = array(
- 'id' => Auth::user()->id,
- 'username' => Auth::user()->username
- );
- }
- return Response::json(array(
- 'error' => $error,
- 'user' => $user
- ), 200);
- }
- else
- {
- return Response::json(array(
- 'error' => $error
- ), 400);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement