public function store() { $input = \Input::all(); $validator = \Validator::make($input, array('username' => array('required'), 'password' => array('required'))); if ($validator->fails()) { throw new NotAuthorizedException(); } $token = $this->driver->attempt(array('email' => $input['username'], 'password' => $input['password'])); if (!$token) { throw new NotAuthorizedException(); } $serializedToken = $this->driver->getProvider()->serializeToken($token); $user = $this->driver->user($token); return \Response::json(array('token' => $serializedToken, 'user' => $user->toArray())); }
public function store() { $input = Input::all(); $validator = Validator::make($input, array('username' => array('required'), 'password' => array('required'))); if ($validator->fails()) { throw new NotAuthorizedException(); } $creds = call_user_func($this->credentialsFormatter, $input['username'], $input['password']); $token = $this->driver->attempt($creds); if (!$token) { throw new NotAuthorizedException(); } $user = $this->driver->user($token); $this->events->fire('auth.token.created', array($user, $token)); $serializedToken = $this->driver->getProvider()->serializeToken($token); return Response::json(array('token' => $serializedToken, 'user' => $user->toArray())); }