]> _ Git - cubist_socialite.git/commitdiff
wip #4765 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Oct 2021 14:32:51 +0000 (16:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Oct 2021 14:32:51 +0000 (16:32 +0200)
.idea/cubist_socialite.iml
resources/views/login.blade.php [new file with mode: 0644]
routes/socialite.php [new file with mode: 0644]
src/Http/Controllers/SocialiteController.php [new file with mode: 0644]
src/SocialiteServiceProvider.php

index d6ebd4805981b8400db3e3291c74a743fef9a824..846927c95ce76961a695347eaa2b3ac93f56bbd3 100644 (file)
@@ -2,7 +2,79 @@
 <module type="JAVA_MODULE" version="4">
   <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
-    <content url="file://$MODULE_DIR$" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Cubist\Socialite\" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/config" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/nette/utils" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/commonmark" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/nesbot/carbon" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/collection" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/mime-type-detection" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/league/oauth1-client" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/nette/schema" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/opis/closure" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/socialiteproviders/google" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/socialiteproviders/manager" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/console" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/css-selector" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-client-contracts" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher-contracts" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/dflydev/dot-access-data" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/laravel/socialite" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/laravel/framework" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/laravel/serializable-closure" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php81" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-iconv" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-grapheme" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation-contracts" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/string" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/dragonmantank/cron-expression" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/graham-campbell/result-type" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/swiftmailer/swiftmailer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/phpoption/phpoption" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
+    </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php
new file mode 100644 (file)
index 0000000..b3d9bbc
--- /dev/null
@@ -0,0 +1 @@
+<?php
diff --git a/routes/socialite.php b/routes/socialite.php
new file mode 100644 (file)
index 0000000..9b1a735
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+Route::get("socialite/login", "SocialiteController@login");
+Route::get("socialite/redirect/{provider}", "SocialiteController@redirect")->name('socialite.redirect');
+Route::get("socialite/callback/{provider}", "SocialiteController@callback")->name('socialite.callback');
\ No newline at end of file
diff --git a/src/Http/Controllers/SocialiteController.php b/src/Http/Controllers/SocialiteController.php
new file mode 100644 (file)
index 0000000..0f2a6da
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Cubist\Socialite\Http\Controllers;
+
+use Cubist\Socialite\SocialiteServiceProvider;
+use Illuminate\Http\Client\Request;
+use Illuminate\Routing\Controller;
+
+class SocialiteController extends Controller
+{
+
+    protected $providers = ["google"];
+
+    public function login()
+    {
+        return view(SocialiteServiceProvider::NAMESPACE . ".login");
+    }
+
+    public function redirect(Request $request)
+    {
+
+        $provider = $request->provider;
+        if (in_array($provider, $this->providers)) {
+            return Socialite::driver($provider)->redirect();
+        }
+        abort(403);
+    }
+
+
+    public function callback(Request $request)
+    {
+
+        $provider = $request->provider;
+        if (in_array($provider, $this->providers)) {
+            $data = Socialite::driver($request->provider)->user();
+            $user = $data->user;
+            dd($user);
+        }
+        abort(403);
+    }
+}
\ No newline at end of file
index e4880ab531401ccbd3b7b7a4db0f9c3ac420347c..8ac9e1c602c36091dcb62c0751d49ddf3181830f 100644 (file)
@@ -7,4 +7,23 @@ use Illuminate\Support\ServiceProvider;
 class SocialiteServiceProvider extends ServiceProvider
 {
 
+    /**
+     * Indicates if loading of the provider is deferred.
+     *
+     * @var bool
+     */
+    protected $defer = false;
+
+    const NAMESPACE = 'cubist_socialite';
+
+    public function boot()
+    {
+        $base = realpath(__DIR__ . "/..");
+        $resourcesDir = $base . '/resources';
+
+        $this->loadTranslationsFrom(realpath($resourcesDir . '/lang'), self::NAMESPACE);
+        $this->loadRoutesFrom($base . '/routes/socialite.php');
+        //$this->publishes([$resourcesDir . '/config/cubist.php' => config_path('cubist.php')], 'config');
+        $this->loadViewsFrom(realpath($resourcesDir . '/views'), self::NAMESPACE);
+    }
 }
\ No newline at end of file