Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
d87383672c
commit
fc4579c47d
8 files changed
+673
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
|
||||
class OAuthController extends Controller
|
||||
{
|
||||
public function redirect(): RedirectResponse
|
||||
{
|
||||
return Socialite::driver('nextcloud')->redirect();
|
||||
}
|
||||
|
||||
public function callback(): RedirectResponse
|
||||
{
|
||||
$socialUser = Socialite::driver('nextcloud')->user();
|
||||
|
||||
$user = User::firstOrCreate(
|
||||
['email' => $socialUser->getEmail()],
|
||||
[
|
||||
'name' => $socialUser->getName() ?? $socialUser->getNickname() ?? $socialUser->getEmail(),
|
||||
'password' => Str::random(40),
|
||||
]
|
||||
);
|
||||
|
||||
Auth::login($user, remember: true);
|
||||
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Models\Product; // Richtiges Product-Model importieren
|
||||
use App\Observers\ProductObserver; // ProductObserver importieren
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use App\Models\Product;
|
||||
use App\Observers\ProductObserver;
|
||||
use SocialiteProviders\Manager\SocialiteWasCalled;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -22,5 +24,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
Product::observe(ProductObserver::class);
|
||||
|
||||
Event::listen(function (SocialiteWasCalled $event) {
|
||||
$event->extendSocialite('nextcloud', \SocialiteProviders\Nextcloud\Provider::class);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,22 @@ class UserPanelProvider extends PanelProvider
|
||||
NavigationGroup::make('Ressourcen'),
|
||||
NavigationGroup::make('CRM'),
|
||||
])
|
||||
->renderHook(
|
||||
PanelsRenderHook::AUTH_LOGIN_FORM_AFTER,
|
||||
fn () => new HtmlString(
|
||||
'<div class="mt-4">'
|
||||
. '<div class="relative flex items-center gap-3 py-1">'
|
||||
. '<div class="h-px flex-1 bg-gray-200 dark:bg-gray-700"></div>'
|
||||
. '<span class="text-xs text-gray-400 dark:text-gray-500">oder</span>'
|
||||
. '<div class="h-px flex-1 bg-gray-200 dark:bg-gray-700"></div>'
|
||||
. '</div>'
|
||||
. '<a href="' . route('auth.nextcloud') . '" class="mt-3 flex w-full items-center justify-center gap-2 rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700">'
|
||||
. '<svg class="h-4 w-4" viewBox="0 0 50 50" fill="currentColor"><path d="M25 2C12.3 2 2 12.3 2 25s10.3 23 23 23 23-10.3 23-23S37.7 2 25 2zm0 7a7 7 0 110 14 7 7 0 010-14zm0 32c-5.8 0-10.9-2.9-14-7.3.1-4.6 9.3-7.2 14-7.2s13.9 2.5 14 7.2C35.9 38.1 30.8 41 25 41z"/></svg>'
|
||||
. 'Mit Nextcloud anmelden'
|
||||
. '</a>'
|
||||
. '</div>'
|
||||
)
|
||||
)
|
||||
->renderHook(
|
||||
PanelsRenderHook::SIDEBAR_FOOTER,
|
||||
fn () => new HtmlString(
|
||||
|
||||
Reference in new issue
Block a user