Skip to content

Instantly share code, notes, and snippets.

@pipethedev
Last active June 18, 2020 09:43
Show Gist options
  • Select an option

  • Save pipethedev/27d7a2ed43d943c9f58afd14d4fdd2cd to your computer and use it in GitHub Desktop.

Select an option

Save pipethedev/27d7a2ed43d943c9f58afd14d4fdd2cd to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Auth;
class SignInController extends Controller
{
public function __invoke(Request $request){
$credentials = request(['email', 'password']);
if (!$token = Auth::attempt($credentials)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return response()->json(compact('token'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment