diff --git a/composer.json b/composer.json index a3d4a07531a3aae4d5913fb842081c729c3f3528..cfa116ed5b6c2fc0ba1ff1ad8e9da20dc04f913b 100644 --- a/composer.json +++ b/composer.json @@ -144,6 +144,12 @@ "drupal/google_analytics_reports": "3.x-dev#2b6bb8efbc7f61ce3c1225638075aa6037b8db44", "drupal/login_destination": "1.x-dev#54be8b89fdc073ca40af6b9b2eeb050e0aeb7908", "drupal/betterlogin": "1.x-dev#f7cf1c5c9ec5e80c6ac0ef04ed605e25495232cd", + "drupal/social_api": "2.0-beta3", + "drupal/social_auth": "2.0-beta3", + "drupal/social_auth_google": "2.0-beta2", + "drupal/social_auth_facebook": "2.0-beta2", + "drupal/social_auth_twitter": "2.0-alpha1", + "drupal/social_auth_linkedin": "2.0-alpha2", "drupal/ckeditor_media_embed": "1.1", "drupal/total_control": "2.0-alpha4", "drupal/anchor_link": "1.x-dev", diff --git a/configbit/extra.components.varbase.bit.yml b/configbit/extra.components.varbase.bit.yml index 5624996f39228160752e4c1172c1e87787ddf38a..b593557eaf494047ed7e872828eb0215a0332388 100644 --- a/configbit/extra.components.varbase.bit.yml +++ b/configbit/extra.components.varbase.bit.yml @@ -34,3 +34,9 @@ config_bit: description: "Provides the necessary tools to build blogs in your website." selected: false config_form: false + varbase_auth: + title: "Varbase Social Single Sign-On" + description: "Adds single sign-on using existing information from a social networking service such as Facebook, Twitter or Google+. Built using <a href=\"https://www.drupal.org/project/social_api\" target=\"_blank\">Social API</a>." + selected: false + config_form: true + formbit: "src/FormBit/varbase_auth.formbit.php" diff --git a/drupal-org.make b/drupal-org.make index 25bd5786f220a0f5f6b22fc2d61508563f07f2bf..fb871bba5cfc5cb46025a6f56823af54af3dea2d 100644 --- a/drupal-org.make +++ b/drupal-org.make @@ -324,6 +324,24 @@ projects[betterlogin][download][url] = https://git.drupal.org/project/betterlogi projects[betterlogin][download][revision] = f7cf1c5c9ec5e80c6ac0ef04ed605e25495232cd projects[betterlogin][download][branch] = 8.x-1.x +projects[social_api][type] = module +projects[social_api][version] = 2.0-beta3 + +projects[social_auth][type] = module +projects[social_auth][version] = 2.0-beta3 + +projects[social_auth_google][type] = module +projects[social_auth_google][version] = 2.0-beta2 + +projects[social_auth_facebook][type] = module +projects[social_auth_facebook][version] = 2.0-beta2 + +projects[social_auth_twitter][type] = module +projects[social_auth_twitter][version] = 2.0-alpha1 + +projects[social_auth_linkedin][type] = module +projects[social_auth_linkedin][version] = 2.0-alpha2 + projects[ckeditor_media_embed][type] = module projects[ckeditor_media_embed][version] = 1.1 ;; Issue #2900313: Add ability to embed tweets and other rich content in WYSIWYG diff --git a/modules/varbase_features/varbase_auth/config/install/block.block.socialauthlogin.yml b/modules/varbase_features/varbase_auth/config/install/block.block.socialauthlogin.yml new file mode 100644 index 0000000000000000000000000000000000000000..ecee71cddd37d0a2e39f1fb4c53d6408b76c0632 --- /dev/null +++ b/modules/varbase_features/varbase_auth/config/install/block.block.socialauthlogin.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + module: + - block_class + - social_auth + - system +third_party_settings: + block_class: + classes: '' +id: socialauthlogin +theme: vartheme +region: content +weight: -7 +provider: null +plugin: social_auth_login +settings: + id: social_auth_login + label: 'Login with' + provider: social_auth + label_display: '0' +visibility: + request_path: + id: request_path + pages: "/user/login\r\n/user/register" + negate: false + context_mapping: { } diff --git a/modules/varbase_features/varbase_auth/varbase_auth.features.yml b/modules/varbase_features/varbase_auth/varbase_auth.features.yml new file mode 100755 index 0000000000000000000000000000000000000000..8ac52eee9b78f26c31dfe33a0489664fcee672ee --- /dev/null +++ b/modules/varbase_features/varbase_auth/varbase_auth.features.yml @@ -0,0 +1,2 @@ +bundle: varbase +required: true diff --git a/modules/varbase_features/varbase_auth/varbase_auth.info.yml b/modules/varbase_features/varbase_auth/varbase_auth.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..cbee5fe663630c5d1b7cf05e908257fdcd9bfddf --- /dev/null +++ b/modules/varbase_features/varbase_auth/varbase_auth.info.yml @@ -0,0 +1,10 @@ +name: 'Varbase Social Single Sign-On' +type: module +description: 'Adds single sign-on using existing information from a social networking service such as Facebook, Twitter or Google+' +core: 8.x +package: Varbase +dependencies: + - block + - block_class + - social_auth + - system diff --git a/modules/varbase_features/varbase_auth/varbase_auth.install b/modules/varbase_features/varbase_auth/varbase_auth.install new file mode 100644 index 0000000000000000000000000000000000000000..3f8d7409dec1c24f238503e24efbec0b1af668e2 --- /dev/null +++ b/modules/varbase_features/varbase_auth/varbase_auth.install @@ -0,0 +1,31 @@ +<?php + +/** + * @file + * Install, update and uninstall functions for the varbase_auth module. + */ + +/** + * Implements hook_install(). + * + * Perform actions related to the installation of varbase_auth. + */ +function varbase_auth_install() { + // Install some additional modules. + _varbase_auth_module_installer(); +} + +/** + * Install some additional modules. + */ +function _varbase_auth_module_installer() { + $configFactory = \Drupal::configFactory()->getEditable('simple.settings'); + $auths = $configFactory->get('social_auth_type'); + $modules = []; + foreach ($auths as $key => $module) { + if (is_string($module)) { + array_push($modules, $module); + } + } + \Drupal::service('module_installer')->install($modules); +} diff --git a/modules/varbase_features/varbase_auth/varbase_auth.module b/modules/varbase_features/varbase_auth/varbase_auth.module new file mode 100644 index 0000000000000000000000000000000000000000..525a2600d0de26cedafab277a2441cb6b3d1c2c6 --- /dev/null +++ b/modules/varbase_features/varbase_auth/varbase_auth.module @@ -0,0 +1,81 @@ +<?php + +/** + * @file + * Contains varbase_auth.module. + */ + +use Drupal\block\Entity\Block; + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function varbase_auth_preprocess(&$variables) { + $moduleHandler = \Drupal::service('module_handler'); + $modules_list = \Drupal::service('module_handler')->getModuleList(); + + $social_flag = TRUE; + + // Check if at least one social auth module is enabled. + foreach ($modules_list as $module => $value) { + if (substr_count($module, 'social_auth_') != 0) { + $social_flag = TRUE; + break; + } + } + + if ($moduleHandler->moduleExists('varbase_auth') && $social_flag) { + $block = Block::load('socialauthlogin'); + $block->set('status', 1); + $block->save(); + + // Add variables to template. + _varbase_auth_add_template_variable($variables, [ + 'modules_enabled' => [ + 'type' => 'bool', + 'value' => 1, + ], + ]); + } + else { + $block = Block::load('socialauthlogin'); + $block->set('status', 0); + $block->save(); + + // Add variables to template. + _varbase_auth_add_template_variable($variables, [ + 'modules_enabled' => [ + 'type' => 'bool', + 'value' => 0 , + ], + ]); + } +} + +/** + * Populates TWIG variables with VARBASE_AUTH related data. + * + * E.g.: $variables['VARBASE_AUTH']['test'] becomes + * {{ VARBASE_AUTH.test }} in the templates. + * + * @param array &$variables + * The core $variables passed by reference. + * @param array $data + * New data in array format, which will be passed to the template. + * + * @return bool|array + * The new data. + * + * @internal + */ +function _varbase_auth_add_template_variable(array &$variables, array $data = NULL) { + static $key = 'VARBASE_AUTH'; + + if (!isset($variables[$key])) { + $variables[$key] = $data; + } + else { + $variables[$key][] = $data; + } + return $data; +} diff --git a/modules/varbase_features/varbase_blog/css/theme/blog.theme.css b/modules/varbase_features/varbase_blog/css/theme/blog.theme.css index c78097db8517af6536ed2ddfbda5146fc0af16ce..95c1863bcaf7e86e93e486fcd29bd28922fea79c 100755 --- a/modules/varbase_features/varbase_blog/css/theme/blog.theme.css +++ b/modules/varbase_features/varbase_blog/css/theme/blog.theme.css @@ -66,24 +66,24 @@ margin-top: 20px; margin-bottom: 20px; } -.blog-menu { +.menu--blog-menu { text-align: center; margin: 20px auto; } -.blog-menu.nav li { +.menu--blog-menu.nav li { display: inline-block; padding-left: 5px; padding-right: 5px; } -.blog-menu.nav li a { +.menu--blog-menu.nav li a { color: #666; font-size: 20px; padding: 0; border-bottom: solid 2px transparent; } -.blog-menu.nav li a:hover, -.blog-menu.nav li a:focus, -.blog-menu.nav li a.is-active { +.menu--blog-menu.nav li a:hover, +.menu--blog-menu.nav li a:focus, +.menu--blog-menu.nav li a.is-active { border-bottom: solid 2px #29aae1; text-decoration: none; background: transparent; diff --git a/modules/varbase_features/varbase_blog/less/theme/blog.theme.less b/modules/varbase_features/varbase_blog/less/theme/blog.theme.less index af97c073821ccc13949b14a01960157688de2b38..5cd85f8612c0ec6005ec9e0a312eec7e01776443 100755 --- a/modules/varbase_features/varbase_blog/less/theme/blog.theme.less +++ b/modules/varbase_features/varbase_blog/less/theme/blog.theme.less @@ -89,7 +89,7 @@ } } -.blog-menu { +.menu--blog-menu { text-align: center; margin: 20px auto; &.nav { diff --git a/src/FormBit/varbase_auth.formbit.php b/src/FormBit/varbase_auth.formbit.php new file mode 100644 index 0000000000000000000000000000000000000000..5759870039a43ad47e7383e398467f480fd396e7 --- /dev/null +++ b/src/FormBit/varbase_auth.formbit.php @@ -0,0 +1,81 @@ +<?php + +/** + * @file + * FormBit file for varbase_auth feature mdoule. + */ + +use Drupal\Core\Form\FormStateInterface; + +/** + * Get editable config names. + * + * @return array + * Array of config names, and list of values. + */ +function varbase_auth_get_editable_config_names() { + $editable_cofnigs = [ + 'simple.settings' => [ + 'social_auth_type' => ['social_auth_google'], + ], + ]; + + return $editable_cofnigs; +} + +/** + * Build form bit. + * + * @param array $formbit + * FormBit for the form. + * @param Drupal\Core\Form\FormStateInterface $form_state + * Form status. + * @param array $install_state + * Install state. + */ +function varbase_auth_build_formbit(array &$formbit, FormStateInterface &$form_state, array &$install_state = NULL) { + $formbit['social_auth_type'] = [ + '#type' => 'checkboxes', + '#title' => t('Social authentications to enable'), + '#default_value' => ['social_auth_google'], + '#options' => [ + 'social_auth_google' => t('Google +'), + 'social_auth_facebook' => t('Facebook'), + 'social_auth_linkedin' => t('Linkedin'), + 'social_auth_twitter' => t('Twitter'), + ], + ]; +} + +/** + * Submit form bit with editable config values. + * + * To update the editable config in drupal active config. + * + * @param array $editable_config_values + * Editable cofnig values. + */ +function varbase_auth_submit_formbit(array $editable_config_values) { + $configFactory = \Drupal::configFactory()->getEditable('simple.settings'); + $configFactory->set('social_auth_type', $editable_config_values['simple.settings']['social_auth_type']); + $configFactory->save(TRUE); + + _varbase_auth_enable_modules(); +} + +/** + * Custom function to get checked values. + * + * From the Config and enable the modules. + */ +function _varbase_auth_enable_modules() { + $configFactory = \Drupal::configFactory()->getEditable('simple.settings'); + $modules = $configFactory->get('social_auth_type'); + if (\Drupal::moduleHandler()->moduleExists('varbase_auth') && $modules != NULL) { + foreach ($modules as $key => $module) { + if (is_string($module)) { + \Drupal::service('module_installer')->install([$module]); + } + } + } +} diff --git a/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css b/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css index d0b859895aab1f53c98721c7d623ba5ed9334454..dffab003a13c88c94dc31ff9fc3b00bf984c510e 100644 --- a/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css +++ b/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css @@ -1,5 +1,6 @@ #auth-box { padding: 50px 0 0; + text-align: center; } #auth-box h1#the-logo { text-align: center; @@ -28,3 +29,22 @@ #auth-box .user-form .form-control { max-width: 100%; } +#auth-box .block-title { + text-align: center; + background: #eeeeee; + height: 1px; + margin: 30px 0; +} +#auth-box .block-title span { + background-color: #ffffff; + text-transform: uppercase; + font-size: 18px; + padding: 0 10px; + background: #fff; + padding: 10px; + position: relative; + top: -20px; +} +#auth-box .user-login-form { + text-align: left; +} diff --git a/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less b/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less index 3bbb81683f21d67fb679e8f70577d120bb897646..1fb35d0efcece6e1c1af89738898a3059d704043 100644 --- a/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less +++ b/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less @@ -8,6 +8,7 @@ #auth-box { padding: @navbar-height 0 0; + text-align: center; h1#the-logo { text-align: center; @@ -43,4 +44,26 @@ max-width: 100%; } } + + .block-title { + text-align: center; + background: #eeeeee; + height: 1px; + margin: 30px 0; + + span { + background-color: #ffffff; + text-transform: uppercase; + font-size: 18px; + padding: 0 10px; + background: #fff; + padding: 10px; + position: relative; + top: -20px; + } + } + + .user-login-form { + text-align: left; + } } diff --git a/themes/vartheme/css/theme/betterlogin.theme.css b/themes/vartheme/css/theme/betterlogin.theme.css index d0b859895aab1f53c98721c7d623ba5ed9334454..df26df4fd5a6921c6a377d709a43f4f0179c1341 100644 --- a/themes/vartheme/css/theme/betterlogin.theme.css +++ b/themes/vartheme/css/theme/betterlogin.theme.css @@ -1,5 +1,6 @@ #auth-box { padding: 50px 0 0; + text-align: center; } #auth-box h1#the-logo { text-align: center; @@ -28,3 +29,23 @@ #auth-box .user-form .form-control { max-width: 100%; } + +#auth-box .block-title { + text-align: center; + background: #eeeeee; + height: 1px; + margin: 30px 0; +} +#auth-box .block-title span { + background-color: #ffffff; + text-transform: uppercase; + font-size: 18px; + padding: 0 10px; + background: #fff; + padding: 10px; + position: relative; + top: -20px; +} +#auth-box .user-login-form { + text-align: left; +} \ No newline at end of file diff --git a/themes/vartheme/less/theme/betterlogin.theme.less b/themes/vartheme/less/theme/betterlogin.theme.less index 9e9f70ea3ee78943010838e5d7a62bb9f6409351..5d5dc08f30bee6b3dce6e67828e0b7b56efdce53 100644 --- a/themes/vartheme/less/theme/betterlogin.theme.less +++ b/themes/vartheme/less/theme/betterlogin.theme.less @@ -8,6 +8,7 @@ #auth-box { padding: @navbar-height 0 0; + text-align: center; h1#the-logo { text-align: center; @@ -43,4 +44,26 @@ max-width: 100%; } } -} \ No newline at end of file + + .block-title { + text-align: center; + background: #eeeeee; + height: 1px; + margin: 30px 0; + + span { + background-color: #ffffff; + text-transform: uppercase; + font-size: 18px; + padding: 0 10px; + background: #fff; + padding: 10px; + position: relative; + top: -20px; + } + } + + .user-login-form { + text-align: left; + } +} diff --git a/themes/vartheme/templates/betterlogin/block--social-auth.html.twig b/themes/vartheme/templates/betterlogin/block--social-auth.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..ac49459a0bd7107f045321204dc5b1607d4ac7cf --- /dev/null +++ b/themes/vartheme/templates/betterlogin/block--social-auth.html.twig @@ -0,0 +1,66 @@ +{# +/** + * @file + * Default theme implementation to display a block. + * + * Available variables: + * - $block->subject: Block title. + * - $content: Block content. + * - $block->module: Module that generated the block. + * - $block->delta: An ID for the block, unique within each module. + * - $block->region: The block region embedding the current block. + * - $classes: String of classes that can be used to style contextually through + * CSS. It can be manipulated through the variable $classes_array from + * preprocess functions. The default values can be one or more of the + * following: + * - block: The current template type, i.e., "theming hook". + * - block-[module]: The module generating the block. For example, the user + * module is responsible for handling the default user navigation block. In + * that case the class would be 'block-user'. + * - $title_prefix (array): An array containing additional output populated by + * modules, intended to be displayed in front of the main title tag that + * appears in the template. + * - $title_suffix (array): An array containing additional output populated by + * modules, intended to be displayed after the main title tag that appears in + * the template. + * + * Helper variables: + * - $classes_array: Array of html class attribute values. It is flattened + * into a string within the variable $classes. + * - $block_zebra: Outputs 'odd' and 'even' dependent on each block region. + * - $zebra: Same output as $block_zebra but independent of any block region. + * - $block_id: Counter dependent on each block region. + * - $id: Same output as $block_id but independent of any block region. + * - $is_front: Flags true when presented in the front page. + * - $logged_in: Flags true when the current user is a logged-in member. + * - $is_admin: Flags true when the current user is an administrator. + * - $block_html_id: A valid HTML ID and guaranteed unique. + * + * @ingroup templates + * + * @see bootstrap_preprocess_block() + * @see template_preprocess() + * @see template_preprocess_block() + * @see bootstrap_process_block() + * @see template_process() + */ +#} +{% + set classes = [ + 'block', + 'block-' ~ configuration.provider|clean_class, + 'block-' ~ plugin_id|clean_class, + 'clearfix', + ] +%} +<section{{ attributes.addClass(classes) }}> + {{ title_prefix }} + {% if label %} + <h2{{ title_attributes.addClass('block-title') }}><span>{{ label }}</span></h2> + {% endif %} + {{ title_suffix }} + + {% block content %} + {{ content }} + {% endblock %} +</section> diff --git a/themes/vartheme/templates/betterlogin/page--user--login.html.twig b/themes/vartheme/templates/betterlogin/page--user--login.html.twig index 88468062d07a5774b28286d107baa5321579da87..9acfa8ed3171e768c0f727401c0691b1657ea885 100644 --- a/themes/vartheme/templates/betterlogin/page--user--login.html.twig +++ b/themes/vartheme/templates/betterlogin/page--user--login.html.twig @@ -21,9 +21,16 @@ {% endif %} </div> <div id="middle-part"> - <h2 class="title">{{ title }}</h2> {{ page.header|without('vartheme_local_tasks', 'vartheme_breadcrumbs', 'vartheme_local_actions', 'vartheme_page_title') }} - {{ page.content }} + {% if (VARBASE_AUTH.modules_enabled.value) and (page.content.socialauthlogin) %} + <h2 class="block-title"><span> {{ "Login with"|t }} </span></h2> + {{ page.content.socialauthlogin }} + <h2 class="block-title"><span> {{ "or"|t }} </span></h2> + {{ page.content|without('socialauthlogin') }} + {% else %} + <h2 class="block-title"><span> {{ title }} </span></h2> + {{ page.content }} + {% endif %} </div> <div id="bottom-part"> <div class="password-link"> diff --git a/themes/vartheme/templates/betterlogin/page--user--register.html.twig b/themes/vartheme/templates/betterlogin/page--user--register.html.twig index e4e2a52511b7995fc5ad715bd0e6a33b744f10a9..3a253c36a15ce898d513635e79c4bc9985283544 100644 --- a/themes/vartheme/templates/betterlogin/page--user--register.html.twig +++ b/themes/vartheme/templates/betterlogin/page--user--register.html.twig @@ -21,9 +21,16 @@ {% endif %} </div> <div id="middle-part"> - <h2 class="title">{{ title }}</h2> {{ page.header|without('vartheme_local_tasks', 'vartheme_breadcrumbs', 'vartheme_local_actions', 'vartheme_page_title') }} - {{ page.content }} + {% if (VARBASE_AUTH.modules_enabled.value) and (page.content.socialauthlogin) %} + <h2 class="block-title"><span> {{ "Sign up with"|t }} </span></h2> + {{ page.content.socialauthlogin }} + <h2 class="block-title"><span> {{ "or"|t }} </span></h2> + {{ page.content|without('socialauthlogin') }} + {% else %} + <h2 class="block-title"><span> {{ title }} </span></h2> + {{ page.content }} + {% endif %} </div> <div id="bottom-part"> {% if not logged_in %}