diff --git a/.env.example b/.env.example index 49f65a19b..c12561de2 100644 --- a/.env.example +++ b/.env.example @@ -47,3 +47,23 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +FACEBOOK_CLIENT_ID= +FACEBOOK_CLIENT_SECRET= +FACEBOOK_CALLBACK_URL=https://yourhost.com/customer/social-login/facebook/callback + +TWITTER_CLIENT_ID= +TWITTER_CLIENT_SECRET= +TWITTER_CALLBACK_URL=https://yourhost.com/customer/social-login/twitter/callback + +GOGGLE_CLIENT_ID= +GOGGLE_CLIENT_SECRET= +GOGGLE_CALLBACK_URL=https://yourhost.com/customer/social-login/google/callback + +LINKEDIN_CLIENT_ID= +LINKEDIN_CLIENT_SECRET= +LINKEDIN_CALLBACK_URL=https://yourhost.com/customer/social-login/linkedin/callback + +GITHUB_CLIENT_ID= +GITHUB_CLIENT_SECRET= +GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback \ No newline at end of file diff --git a/composer.json b/composer.json index 7845a065e..4a7a583a5 100755 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ "kalnoy/nestedset": "5.0.1", "konekt/concord": "^1.2", "laravel/framework": "^7.0", + "laravel/socialite": "^4.4", "laravel/tinker": "^2.0", "laravel/ui": "^2.0", "maatwebsite/excel": "3.1.19", @@ -103,7 +104,8 @@ "Webkul\\Rule\\": "packages/Webkul/Rule/src", "Webkul\\CMS\\": "packages/Webkul/CMS/src", "Webkul\\Velocity\\": "packages/Webkul/Velocity/src", - "Webkul\\BookingProduct\\": "packages/Webkul/BookingProduct/src" + "Webkul\\BookingProduct\\": "packages/Webkul/BookingProduct/src", + "Webkul\\SocialLogin\\": "packages/Webkul/SocialLogin/src" } }, diff --git a/composer.lock b/composer.lock index c97a7cf2f..0583a4c69 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8aafae843c854c6ea581deb957563009", + "content-hash": "a64bc9824943e94bc0643161f1bb59d4", "packages": [ { "name": "astrotomic/laravel-translatable", @@ -1825,6 +1825,71 @@ ], "time": "2020-06-02T22:34:18+00:00" }, + { + "name": "laravel/socialite", + "version": "v4.4.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/socialite.git", + "reference": "80951df0d93435b773aa00efe1fad6d5015fac75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/socialite/zipball/80951df0d93435b773aa00efe1fad6d5015fac75", + "reference": "80951df0d93435b773aa00efe1fad6d5015fac75", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^6.0|^7.0", + "illuminate/http": "~5.7.0|~5.8.0|^6.0|^7.0", + "illuminate/support": "~5.7.0|~5.8.0|^6.0|^7.0", + "league/oauth1-client": "^1.0", + "php": "^7.1.3" + }, + "require-dev": { + "illuminate/contracts": "~5.7.0|~5.8.0|^6.0|^7.0", + "mockery/mockery": "^1.0", + "orchestra/testbench": "^3.7|^3.8|^4.0|^5.0", + "phpunit/phpunit": "^7.0|^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Socialite\\SocialiteServiceProvider" + ], + "aliases": { + "Socialite": "Laravel\\Socialite\\Facades\\Socialite" + } + } + }, + "autoload": { + "psr-4": { + "Laravel\\Socialite\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel wrapper around OAuth 1 & OAuth 2 libraries.", + "homepage": "https://laravel.com", + "keywords": [ + "laravel", + "oauth" + ], + "time": "2020-06-03T13:30:03+00:00" + }, { "name": "laravel/tinker", "version": "v2.4.0", @@ -2199,6 +2264,69 @@ ], "time": "2020-05-18T15:13:39+00:00" }, + { + "name": "league/oauth1-client", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/oauth1-client.git", + "reference": "fca5f160650cb74d23fc11aa570dd61f86dcf647" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/fca5f160650cb74d23fc11aa570dd61f86dcf647", + "reference": "fca5f160650cb74d23fc11aa570dd61f86dcf647", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "php": ">=5.5.0" + }, + "require-dev": { + "mockery/mockery": "^0.9", + "phpunit/phpunit": "^4.0", + "squizlabs/php_codesniffer": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "League\\OAuth1\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ben Corlett", + "email": "bencorlett@me.com", + "homepage": "http://www.webcomm.com.au", + "role": "Developer" + } + ], + "description": "OAuth 1.0 Client Library", + "keywords": [ + "Authentication", + "SSO", + "authorization", + "bitbucket", + "identity", + "idp", + "oauth", + "oauth1", + "single sign on", + "trello", + "tumblr", + "twitter" + ], + "time": "2016-08-17T00:36:58+00:00" + }, { "name": "maatwebsite/excel", "version": "3.1.19", diff --git a/config/app.php b/config/app.php index 8cd62b101..83a642e1d 100755 --- a/config/app.php +++ b/config/app.php @@ -268,6 +268,7 @@ return [ Webkul\CMS\Providers\CMSServiceProvider::class, Webkul\Velocity\Providers\VelocityServiceProvider::class, Webkul\BookingProduct\Providers\BookingProductServiceProvider::class, + Webkul\SocialLogin\Providers\SocialLoginServiceProvider::class, ], /* diff --git a/config/concord.php b/config/concord.php index e942abaa9..c42dedbaa 100755 --- a/config/concord.php +++ b/config/concord.php @@ -24,5 +24,6 @@ return [ \Webkul\CartRule\Providers\ModuleServiceProvider::class, \Webkul\CMS\Providers\ModuleServiceProvider::class, \Webkul\Velocity\Providers\ModuleServiceProvider::class, + \Webkul\SocialLogin\Providers\ModuleServiceProvider::class, ] ]; \ No newline at end of file diff --git a/config/services.php b/config/services.php index f198a9ca1..772e17f7f 100755 --- a/config/services.php +++ b/config/services.php @@ -46,5 +46,35 @@ return [ 'model' => App\User::class, 'key' => env('STRIPE_KEY'), 'secret' => env('STRIPE_SECRET'), - ] + ], + + 'facebook' => [ + 'client_id' => env('FACEBOOK_CLIENT_ID'), + 'client_secret' => env('FACEBOOK_CLIENT_SECRET'), + 'redirect' => env('FACEBOOK_CALLBACK_URL'), + ], + + 'twitter' => [ + 'client_id' => env('TWITTER_CLIENT_ID'), + 'client_secret' => env('TWITTER_CLIENT_SECRET'), + 'redirect' => env('TWITTER_CALLBACK_URL'), + ], + + 'google' => [ + 'client_id' => env('GOOGLE_CLIENT_ID'), + 'client_secret' => env('GOOGLE_CLIENT_SECRET'), + 'redirect' => env('GOOGLE_CALLBACK_URL'), + ], + + 'linkedin' => [ + 'client_id' => env('LINKEDIN_CLIENT_ID'), + 'client_secret' => env('LINKEDIN_CLIENT_SECRET'), + 'redirect' => env('LINKEDIN_CALLBACK_URL'), + ], + + 'github' => [ + 'client_id' => env('GITHUB_CLIENT_ID'), + 'client_secret' => env('GITHUB_CLIENT_SECRET'), + 'redirect' => env('GITHUB_CALLBACK_URL'), + ], ]; diff --git a/packages/Webkul/SocialLogin/.gitignore b/packages/Webkul/SocialLogin/.gitignore new file mode 100755 index 000000000..6376db975 --- /dev/null +++ b/packages/Webkul/SocialLogin/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/package-lock.json +npm-debug.log \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/package.json b/packages/Webkul/SocialLogin/package.json new file mode 100644 index 000000000..ee28de9fc --- /dev/null +++ b/packages/Webkul/SocialLogin/package.json @@ -0,0 +1,19 @@ +{ + "private": true, + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "cross-env npm run watch -- --watch-poll --progress", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + }, + "devDependencies": { + "cross-env": "^6.0.3", + "laravel-mix": "^5.0.0", + "laravel-mix-merge-manifest": "^0.1.2", + "sass": "^1.25.0", + "sass-loader": "^8.0.2" + } +} diff --git a/packages/Webkul/SocialLogin/publishable/assets/css/social-login.css b/packages/Webkul/SocialLogin/publishable/assets/css/social-login.css new file mode 100644 index 000000000..5b293c781 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/css/social-login.css @@ -0,0 +1 @@ +.social-login-links .icon{width:18px;height:18px;vertical-align:middle;margin-bottom:3px;margin-right:3px;display:inline-block;background-size:cover}.social-login-links .icon.icon-facebook{background-image:url(../images/facebook.svg)}.social-login-links .icon.icon-twitter{background-image:url(../images/twitter.svg)}.social-login-links .icon.icon-google{background-image:url(../images/google.svg)}.social-login-links .icon.icon-linkedin{background-image:url(../images/linkedin.svg)}.social-login-links .icon.icon-github{background-image:url(../images/github.svg)}.social-login-links .icon.icon-instagram{background-image:url(../images/instagram.svg)}.auth-content .login-form .social-login-links .control-group,.auth-content .social-login-links .control-group{float:left;width:100%;margin-bottom:10px!important}.social-login-links .link{min-width:220px;max-width:100%;margin:0;cursor:pointer;padding:10px 15px;border-radius:3px;color:#fff;text-decoration:none;float:left}.social-login-links .link.facebook-link{background-color:#5272b3}.social-login-links .link.twitter-link{background-color:#0597e6}.social-login-links .link.google-link{background-color:#e45e52}.social-login-links .link.linkedin-link{background-color:#007bb6}.social-login-links .link.github-link{background-color:#24292e}.social-link-seperator{position:relative;border-top:1px solid #d3d3d3;margin:30px 0 25px;display:inline-block;width:100%}.social-link-seperator span{background-color:#fff;position:absolute;left:20px;top:-12px;padding:0 15px;text-align:center} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/facebook.svg b/packages/Webkul/SocialLogin/publishable/assets/images/facebook.svg new file mode 100644 index 000000000..72b5ecfa2 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/facebook.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/github.svg b/packages/Webkul/SocialLogin/publishable/assets/images/github.svg new file mode 100644 index 000000000..2a07790f5 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/github.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/google.svg b/packages/Webkul/SocialLogin/publishable/assets/images/google.svg new file mode 100644 index 000000000..e8b58b638 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/google.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/instagram.svg b/packages/Webkul/SocialLogin/publishable/assets/images/instagram.svg new file mode 100644 index 000000000..13e37b9af --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/instagram.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/linkedin.svg b/packages/Webkul/SocialLogin/publishable/assets/images/linkedin.svg new file mode 100644 index 000000000..521b633c3 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/linkedin.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/images/twitter.svg b/packages/Webkul/SocialLogin/publishable/assets/images/twitter.svg new file mode 100644 index 000000000..780e40118 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/images/twitter.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/publishable/assets/mix-manifest.json b/packages/Webkul/SocialLogin/publishable/assets/mix-manifest.json new file mode 100644 index 000000000..a75f04943 --- /dev/null +++ b/packages/Webkul/SocialLogin/publishable/assets/mix-manifest.json @@ -0,0 +1,3 @@ +{ + "/css/social-login.css": "/css/social-login.css?id=5da779505c056aa1ec52" +} diff --git a/packages/Webkul/SocialLogin/src/Config/system.php b/packages/Webkul/SocialLogin/src/Config/system.php new file mode 100644 index 000000000..28fb26269 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Config/system.php @@ -0,0 +1,37 @@ + 'customer.settings.social_login', + 'name' => 'sociallogin::app.admin.system.social-login', + 'sort' => 4, + 'fields' => [ + [ + 'name' => 'enable_facebook', + 'title' => 'sociallogin::app.admin.system.enable-facebook', + 'type' => 'boolean', + 'channel_based' => true, + ], [ + 'name' => 'enable_twitter', + 'title' => 'sociallogin::app.admin.system.enable-twitter', + 'type' => 'boolean', + 'channel_based' => true, + ], [ + 'name' => 'enable_google', + 'title' => 'sociallogin::app.admin.system.enable-google', + 'type' => 'boolean', + 'channel_based' => true, + ], [ + 'name' => 'enable_linkedin', + 'title' => 'sociallogin::app.admin.system.enable-linkedin', + 'type' => 'boolean', + 'channel_based' => true, + ], [ + 'name' => 'enable_github', + 'title' => 'sociallogin::app.admin.system.enable-github', + 'type' => 'boolean', + 'channel_based' => true, + ] + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Contracts/CustomerSocialAccount.php b/packages/Webkul/SocialLogin/src/Contracts/CustomerSocialAccount.php new file mode 100644 index 000000000..4eb2714ef --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Contracts/CustomerSocialAccount.php @@ -0,0 +1,7 @@ +increments('id'); + $table->string('provider_name')->nullable(); + $table->string('provider_id')->unique()->nullable(); + + $table->integer('customer_id')->unsigned(); + $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('customer_social_accounts'); + } +} diff --git a/packages/Webkul/SocialLogin/src/Database/Migrations/2020_06_25_162340_change_email_password_columns_in_customers_table.php b/packages/Webkul/SocialLogin/src/Database/Migrations/2020_06_25_162340_change_email_password_columns_in_customers_table.php new file mode 100644 index 000000000..ec7e1e609 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Database/Migrations/2020_06_25_162340_change_email_password_columns_in_customers_table.php @@ -0,0 +1,34 @@ +string('email')->unique()->nullable()->change(); + $table->string('password')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('customers', function (Blueprint $table) { + $table->string('email')->unique()->nullable(false)->change(); + $table->string('password')->nullable(false)->change(); + }); + } +} diff --git a/packages/Webkul/SocialLogin/src/Http/Controllers/LoginController.php b/packages/Webkul/SocialLogin/src/Http/Controllers/LoginController.php new file mode 100644 index 000000000..b34ebc112 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Http/Controllers/LoginController.php @@ -0,0 +1,73 @@ +customerSocialAccountRepository = $customerSocialAccountRepository; + + $this->_config = request('_config'); + } + + /** + * Redirects to the social provider + * + * @param string $provider + * @return \Illuminate\Http\Response + */ + public function redirectToProvider($provider) + { + return Socialite::driver($provider)->redirect(); + } + + /** + * Handles callback + * + * @param string $provider + * @return \Illuminate\Http\Response + */ + public function handleProviderCallback($provider) + { + try { + $user = Socialite::driver($provider)->user(); + } catch (\Exception $e) { + return redirect()->route('customer.session.index'); + } + + $customer = $this->customerSocialAccountRepository->findOrCreateCustomer($user, $provider); + + auth()->guard('customer')->login($customer, true); + + return redirect()->intended(route($this->_config['redirect'])); + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Http/routes.php b/packages/Webkul/SocialLogin/src/Http/routes.php new file mode 100644 index 000000000..3ea7e2488 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Http/routes.php @@ -0,0 +1,13 @@ + ['web', 'locale', 'theme', 'currency']], function () { + Route::prefix('customer')->group(function () { + Route::get('social-login/{provider}', 'Webkul\SocialLogin\Http\Controllers\LoginController@redirectToProvider')->defaults('_config', [ + 'redirect' => 'customer.profile.index' + ])->name('customer.social-login.index'); + + Route::get('social-login/{provider}/callback','Webkul\SocialLogin\Http\Controllers\LoginController@handleProviderCallback')->defaults('_config', [ + 'redirect' => 'customer.profile.index' + ])->name('customer.social-login.callback'); + }); +}); \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccount.php b/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccount.php new file mode 100644 index 000000000..7010878d4 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccount.php @@ -0,0 +1,24 @@ +belongsTo(CustomerProxy::modelClass()); + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccountProxy.php b/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccountProxy.php new file mode 100644 index 000000000..e5543baf0 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Models/CustomerSocialAccountProxy.php @@ -0,0 +1,10 @@ +addTemplate('sociallogin::shop.customers.session.social-links'); + }); + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Providers/ModuleServiceProvider.php b/packages/Webkul/SocialLogin/src/Providers/ModuleServiceProvider.php new file mode 100644 index 000000000..8771baace --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Providers/ModuleServiceProvider.php @@ -0,0 +1,12 @@ +loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'sociallogin'); + + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'sociallogin'); + + $this->publishes([ + __DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'), + ], 'public'); + + $this->app->register(EventServiceProvider::class); + } + + /** + * Register services. + * + * @return void + */ + public function register() + { + $this->registerConfig(); + } + + /** + * Register package config. + * + * @return void + */ + protected function registerConfig() + { + $this->mergeConfigFrom( + dirname(__DIR__) . '/Config/system.php', 'core' + ); + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Repositories/CustomerSocialAccountRepository.php b/packages/Webkul/SocialLogin/src/Repositories/CustomerSocialAccountRepository.php new file mode 100644 index 000000000..c7c819a70 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Repositories/CustomerSocialAccountRepository.php @@ -0,0 +1,105 @@ +customerRepository = $customerRepository; + + $this->_config = request('_config'); + + parent::__construct($app); + } + + /** + * Specify Model class name + * + * @return string + */ + public function model() + { + return 'Webkul\SocialLogin\Contracts\CustomerSocialAccount'; + } + + /** + * @param array $providerUser + * @param string $provider + * @return void + */ + public function findOrCreateCustomer($providerUser, $provider) + { + $account = $this->findOneWhere([ + 'provider_name' => $provider, + 'provider_id' => $providerUser->getId(), + ]); + + if ($account) { + return $account->customer; + } else { + $customer = $this->customerRepository->findOneByField('email', $providerUser->getEmail()); + + if (! $customer) { + $names = $this->getFirstLastName($providerUser->getName()); + + $customer = $this->customerRepository->create([ + 'email' => $providerUser->getEmail(), + 'first_name' => $names['first_name'], + 'last_name' => $names['last_name'], + 'status' => 1, + 'is_verified' => 1, + ]); + } + + $this->create([ + 'customer_id' => $customer->id, + 'provider_id' => $providerUser->getId(), + 'provider_name' => $provider, + ]); + + return $customer; + } + } + + /** + * Returns first and last name from name + * + * @param string $name + * @return string + */ + public function getFirstLastName($name) + { + $name = trim($name); + + $lastName = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name); + + $firstName = trim( preg_replace('#' . $lastName . '#', '', $name) ); + + return [ + 'first_name' => $firstName, + 'last_name' => $lastName, + ]; + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Resources/.DS_Store b/packages/Webkul/SocialLogin/src/Resources/.DS_Store new file mode 100644 index 000000000..a5c2d92c1 Binary files /dev/null and b/packages/Webkul/SocialLogin/src/Resources/.DS_Store differ diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/facebook.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/facebook.svg new file mode 100644 index 000000000..72b5ecfa2 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/facebook.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/github.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/github.svg new file mode 100644 index 000000000..2a07790f5 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/github.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/google.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/google.svg new file mode 100644 index 000000000..e8b58b638 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/google.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/instagram.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/instagram.svg new file mode 100644 index 000000000..13e37b9af --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/instagram.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/linkedin.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/linkedin.svg new file mode 100644 index 000000000..521b633c3 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/linkedin.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/images/twitter.svg b/packages/Webkul/SocialLogin/src/Resources/assets/images/twitter.svg new file mode 100644 index 000000000..780e40118 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/images/twitter.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/sass/app.scss b/packages/Webkul/SocialLogin/src/Resources/assets/sass/app.scss new file mode 100644 index 000000000..933086aa6 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/sass/app.scss @@ -0,0 +1,59 @@ +@import "icons"; + +.auth-content .login-form .social-login-links .control-group, +.auth-content .social-login-links .control-group { + float: left; + width: 100%; + margin-bottom: 10px !important; +} + +.social-login-links { + .link { + min-width: 220px; + max-width: 100%; + margin: 0px; + cursor: pointer; + padding: 10px 15px; + border-radius: 3px; + color: #FFFFFF; + text-decoration: none; + float: left; + + &.facebook-link { + background-color: #5272B3; + } + + &.twitter-link { + background-color: #0597E6; + } + + &.google-link { + background-color: #E45E52; + } + + &.linkedin-link { + background-color: #007BB6; + } + + &.github-link { + background-color: #24292E; + } + } +} + +.social-link-seperator { + position: relative; + border-top: solid 1px #D3D3D3; + margin: 30px 0px 25px 0px; + display: inline-block; + width: 100%; + + span { + background-color: #FFFFFF; + position: absolute; + left: 20px; + top: -12px; + padding: 0px 15px; + text-align: center; + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Resources/assets/sass/icons.scss b/packages/Webkul/SocialLogin/src/Resources/assets/sass/icons.scss new file mode 100644 index 000000000..86ca04859 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/assets/sass/icons.scss @@ -0,0 +1,35 @@ +.social-login-links { + .icon { + width: 18px; + height: 18px; + vertical-align: middle; + margin-bottom: 3px; + margin-right: 3px; + display: inline-block; + background-size: cover; + + &.icon-facebook { + background-image: url("../images/facebook.svg"); + } + + &.icon-twitter { + background-image: url("../images/twitter.svg"); + } + + &.icon-google { + background-image: url("../images/google.svg"); + } + + &.icon-linkedin { + background-image: url("../images/linkedin.svg"); + } + + &.icon-github { + background-image: url("../images/github.svg"); + } + + &.icon-instagram { + background-image: url("../images/instagram.svg"); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Resources/lang/en/app.php b/packages/Webkul/SocialLogin/src/Resources/lang/en/app.php new file mode 100644 index 000000000..abb58ee66 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/lang/en/app.php @@ -0,0 +1,28 @@ + [ + 'system' => [ + 'social-login' => 'Social Login', + 'enable-facebook' => 'Enable Facebook', + 'enable-twitter' => 'Enable Twitter', + 'enable-google' => 'Enable Google', + 'enable-twitter' => 'Enable Twitter', + 'enable-linkedin' => 'Enable LinkedIn', + 'enable-github' => 'Enable Github' + ] + ], + + 'shop' => [ + 'customer' => [ + 'login-form' => [ + 'continue-with-facebook' => 'Continue With Facebook', + 'continue-with-twitter' => 'Continue With Twitter', + 'continue-with-google' => 'Continue With Google', + 'continue-with-linkedin' => 'Continue With LinkedIn', + 'continue-with-github' => 'Continue With Github', + 'or' => 'Or' + ] + ] + ] +]; \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/src/Resources/views/shop/customers/session/social-links.blade.php b/packages/Webkul/SocialLogin/src/Resources/views/shop/customers/session/social-links.blade.php new file mode 100644 index 000000000..c9de64888 --- /dev/null +++ b/packages/Webkul/SocialLogin/src/Resources/views/shop/customers/session/social-links.blade.php @@ -0,0 +1,61 @@ +@if (core()->getConfigData('customer.settings.social_login.enable_facebook') + || core()->getConfigData('customer.settings.social_login.enable_twitter') + || core()->getConfigData('customer.settings.social_login.enable_google') + || core()->getConfigData('customer.settings.social_login.enable_linkedin') + || core()->getConfigData('customer.settings.social_login.enable_github') +) +@push('css') + +@endpush + + + + +@endif \ No newline at end of file diff --git a/packages/Webkul/SocialLogin/webpack.mix.js b/packages/Webkul/SocialLogin/webpack.mix.js new file mode 100644 index 000000000..b45e9072e --- /dev/null +++ b/packages/Webkul/SocialLogin/webpack.mix.js @@ -0,0 +1,31 @@ +const mix = require("laravel-mix"); + +if (mix == 'undefined') { + const { mix } = require("laravel-mix"); +} + +require("laravel-mix-merge-manifest"); + +if (mix.inProduction()) { + var publicPath = 'publishable/assets'; +} else { + var publicPath = "../../../public/themes/default/assets"; +} + +mix.setPublicPath(publicPath).mergeManifest(); +mix.disableNotifications(); + +mix.copyDirectory(__dirname + "/src/Resources/assets/images", publicPath + "/images") + .sass(__dirname + "/src/Resources/assets/sass/app.scss", "css/social-login.css") + .options({ + processCssUrls: false + }); + + +if (! mix.inProduction()) { + mix.sourceMaps(); +} + +if (mix.inProduction()) { + mix.version(); +} \ No newline at end of file diff --git a/packages/Webkul/Velocity/src/Resources/assets/sass/icons.scss b/packages/Webkul/Velocity/src/Resources/assets/sass/icons.scss index 2a7dbfcc4..d70a71732 100644 --- a/packages/Webkul/Velocity/src/Resources/assets/sass/icons.scss +++ b/packages/Webkul/Velocity/src/Resources/assets/sass/icons.scss @@ -15,5 +15,4 @@ &.velocity-icon { background-image: url("../images/Icon-Velocity-Active.svg"); } -} - +} \ No newline at end of file