Skip to content

feat:LAR-186 add connexion tab in profil with connection account #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ GOOGLE_RECAPTCHA_SITE_KEY=your-recaptcha-site-key
GOOGLE_RECAPTCHA_SECRET_KEY=your-secret-key

GITHUB_FINE_GRAINED_TOKEN=

DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_REDIRECT_URI=${APP_URL}/auth/discord/callback
11 changes: 11 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use SocialiteProviders\Discord\Provider;
use SocialiteProviders\Manager\SocialiteWasCalled;

final class AppServiceProvider extends ServiceProvider
{
Expand All @@ -44,6 +47,7 @@ public function boot(): void
$this->configureSeo();
$this->configureCommands();
$this->configureUrl();
$this->configureCustomSocialProvider();
}

public function registerBladeDirective(): void
Expand Down Expand Up @@ -149,4 +153,11 @@ protected function configureUrl(): void
URL::forceScheme('https');
}
}

protected function configureCustomSocialProvider(): void
{
Event::listen(function (SocialiteWasCalled $event): void {
$event->extendSocialite('discord', Provider::class);
});
}
}
2 changes: 1 addition & 1 deletion app/Traits/HasSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait HasSocialite
*/
public function getAcceptedProviders(): array
{
return ['github'];
return ['github', 'discord'];
}

protected function getSocialiteUser(string $provider): User
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"qcod/laravel-gamify": "1.0.8",
"ramsey/uuid": "^4.7.4",
"sentry/sentry-laravel": "^4.10",
"socialiteproviders/discord": "^4.2",
"spatie/laravel-data": "^4.10",
"spatie/laravel-feed": "^4.2.1",
"spatie/laravel-google-fonts": "^1.2.3",
Expand Down
130 changes: 127 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
'access_secret' => env('TWITTER_ACCESS_SECRET'),
],

'discord' => [
'client_id' => env('DISCORD_CLIENT_ID'),
'client_secret' => env('DISCORD_CLIENT_SECRET'),
'redirect' => env('DISCORD_REDIRECT_URI'),
],

'unsplash' => [
'access_key' => env('UNSPLASH_ACCESS_KEY'),
],
Expand Down
1 change: 1 addition & 0 deletions lang/en/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'preferences' => 'Preferences',
'notifications' => 'Notifications',
'subscription' => 'Subscription',
'connexion' => 'Connexions',
],
'footer' => [
'title' => 'Footer',
Expand Down
1 change: 1 addition & 0 deletions lang/en/pages/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'empty_articles' => "hasn't written any articles yet",
'empty_discussions' => 'has not yet started discussions',
'empty_threads' => 'has not posted any topics yet',
'empty_connexion' => 'has no connection yet',
],

'settings' => [
Expand Down
1 change: 1 addition & 0 deletions lang/fr/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'preferences' => 'Préférences',
'notifications' => 'Notifications',
'subscription' => 'Abonnement',
'connexion' => 'Connexions',
],
'footer' => [
'title' => 'Pied de page',
Expand Down
1 change: 1 addition & 0 deletions lang/fr/pages/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'empty_articles' => "n'a pas encore rédigé d'articles",
'empty_discussions' => "n'a pas encore démarré de discussions",
'empty_threads' => "n'a pas encore posté de sujets",
'empty_connexion' => 'n\'a pas encore de connexion',
],

'settings' => [
Expand Down
62 changes: 62 additions & 0 deletions resources/views/components/user/connexion.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@props([
'user',
])

@if ($user->providers->isNotEmpty())
<div class="relative -mt-6 divide-y divide-gray-200 dark:divide-white/20">
<div class="mt-5 flex items-center gap-4">
@php
$providerUrls = [
'github' => 'https://github.com/' . $user->githubUsername(),
];
@endphp

@foreach($user->providers() as $provider)
@if (array_key_exists($provider->provider, $providerUrls))
<a
href="{{ $providerUrls[$provider->provider] }}"
target="_blank"
class="text-sm text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"
>
<span class="sr-only">{{ ucfirst($provider->provider) }}</span>
<x-icon.{{ $provider->provider }} class="size-6" aria-hidden="true" />
</a>
@endif
@endforeach
</div>
</div>
@else
<x-empty-state>
<div class="relative">
<div class="relative">
<div class="absolute -inset-1 bg-gradient-to-r rotate-3 w-72 from-flag-green to-flag-red rounded-lg blur opacity-25"></div>
<div class="relative z-20 bg-white gap-3 rotate-3 p-3 w-72 rounded-lg shadow ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="space-y-2">
<div class="grid grid-cols-3 gap-2 w-1/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-4 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
</div>
<div class="absolute transform scale-[0.8] bottom-10 right-2 shadow w-40 -rotate-6 z-20 bg-white gap-3 p-3 rounded-lg ring-1 ring-gray-200/50 dark:bg-gray-900 dark:ring-white/10">
<div class="space-y-2">
<div class="grid grid-cols-3 gap-2 w-2/3">
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
<div class="h-3 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded dark:bg-gray-800"></div>
</div>
<div class="h-2 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
<div class="h-6 bg-gray-50 ring-1 ring-gray-200/50 dark:ring-white/20 rounded-md dark:bg-gray-800"></div>
</div>
</div>
</div>
<div class="mt-8 space-y-4">
<p class="mt-8 text-base text-gray-500 dark:text-gray-400">
<span class="font-medium text-gray-700 dark:text-gray-300">{{ $user->name }}</span>
{{ __('pages/account.activities.empty_connexion') }}
</p>
</div>
</x-empty-state>
@endif
8 changes: 6 additions & 2 deletions resources/views/livewire/pages/account/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ class="text-sm text-gray-500 dark:text-gray-500 hover:text-gray-900 dark:hover:t
</div>
<div
x-ref="tabButtons"
class="relative inline-grid h-10 w-full select-none grid-cols-3 items-center justify-center rounded-lg dark:bg-gray-900 p-1 text-gray-600 dark:text-gray-300 lg:max-w-sm"
class="relative inline-grid h-10 w-full select-none grid-cols-4 items-center justify-center rounded-lg dark:bg-gray-900 p-1 text-gray-600 dark:text-gray-300 lg:max-w-sm"
>
@foreach([
__('global.navigation.articles'),
__('global.navigation.discussions'),
__('global.navigation.questions')
__('global.navigation.questions'),
__('global.navigation.connexion'),
] as $tab)
<button
:id="$id(tabId)"
Expand Down Expand Up @@ -148,6 +149,9 @@ class="relative z-20 inline-flex h-8 w-full cursor-pointer items-center justify-
<div x-cloak :id="$id(tabId + '-content')" x-show="tabContentActive($el)">
<x-user.threads :user="$user" :threads="$this->threads" />
</div>
<div x-cloak :id="$id(tabId + '-content')" x-show="tabContentActive($el)">
<x-user.connexion :user="$user" />
</div>
</div>
<aside class="hidden lg:block">
<livewire:components.user.activities :user="$user" />
Expand Down
7 changes: 6 additions & 1 deletion resources/views/partials/_socials-link.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
</div>

<div class="mt-6">
<div>
<div class="space-y-4">
<a href="{{ route('social.auth', ['provider' => 'github']) }}" class="w-full gap-2 inline-flex justify-center py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900">
<span class="sr-only">{{ __('pages/auth.continue_with', ['social' => 'Github']) }}</span>
<x-icon.github class="size-5" aria-hidden="true" />
Github
</a>
<a href="{{ route('social.auth', ['provider' => 'discord']) }}" class="w-full gap-2 inline-flex justify-center py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900">
<span class="sr-only">{{ __('pages/auth.continue_with', ['social' => 'Discord']) }}</span>
<x-icon.discord class="size-5 text-indigo-500" aria-hidden="true" />
Discord
</a>
</div>
</div>
</div>
Loading