mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
add models, setup livewire, setup mongodb
This commit is contained in:
parent
c0590a3412
commit
be4c848eee
27 changed files with 2508 additions and 0 deletions
39
app/Http/Controllers/AuthController.php
Normal file
39
app/Http/Controllers/AuthController.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function handleRedirect()
|
||||
{
|
||||
return Socialite::driver('authentik')->redirect();
|
||||
}
|
||||
|
||||
public function handleCallback()
|
||||
{
|
||||
$user = Socialite::driver('authentik')->user();
|
||||
|
||||
$authUser = User::updateOrCreate(
|
||||
[ 'email' => $user->getEmail() ],
|
||||
[ 'name' => $user->getName() ]
|
||||
);
|
||||
|
||||
if ($authUser)
|
||||
{
|
||||
Auth::login($authUser);
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
abort(401);
|
||||
}
|
||||
|
||||
public function handleLogout()
|
||||
{
|
||||
Auth::logout();
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue