From c753db4eb09696778e7a5124c048b64c5d2c27bd Mon Sep 17 00:00:00 2001
From: Rajab Natshah <rajabn@gmail.com>
Date: Sun, 7 Jan 2018 18:05:40 +0200
Subject: [PATCH] Issue #2933028: Added [Better Login] module 1.x-dev and style
 for vartheme and VARTHEM_SUBTHEME

---
 composer.json                                 |  1 +
 drupal-org.make                               |  5 +++
 .../varbase_core/varbase_core.module          |  8 ++++
 .../02-01-request-new-password.feature        |  2 +-
 .../VARTHEME_SUBTHEME.libraries.yml           |  8 +++-
 .../VARTHEME_SUBTHEME.starterkit.yml          |  6 ++-
 .../css/theme/betterlogin.theme.css           | 27 +++++++++++++
 .../less/theme/betterlogin.theme.less         | 40 +++++++++++++++++++
 .../vartheme/css/theme/betterlogin.theme.css  | 27 +++++++++++++
 .../less/theme/betterlogin.theme.less         | 40 +++++++++++++++++++
 .../betterlogin/page--user--login.html.twig   | 34 ++++++++++++++++
 .../page--user--password.html.twig            | 36 +++++++++++++++++
 .../page--user--register.html.twig            | 31 ++++++++++++++
 .../betterlogin/page--user--reset.html.twig   | 36 +++++++++++++++++
 themes/vartheme/vartheme.info.yml             |  8 +++-
 themes/vartheme/vartheme.libraries.yml        | 12 ++++--
 varbase.info.yml                              |  1 +
 varbase.install                               |  9 +++++
 18 files changed, 323 insertions(+), 8 deletions(-)
 create mode 100644 themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css
 create mode 100644 themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less
 create mode 100644 themes/vartheme/css/theme/betterlogin.theme.css
 create mode 100644 themes/vartheme/less/theme/betterlogin.theme.less
 create mode 100644 themes/vartheme/templates/betterlogin/page--user--login.html.twig
 create mode 100644 themes/vartheme/templates/betterlogin/page--user--password.html.twig
 create mode 100644 themes/vartheme/templates/betterlogin/page--user--register.html.twig
 create mode 100644 themes/vartheme/templates/betterlogin/page--user--reset.html.twig

diff --git a/composer.json b/composer.json
index 5b5b646f..45e61227 100644
--- a/composer.json
+++ b/composer.json
@@ -140,6 +140,7 @@
     "drupal/charts": "3.0-alpha7",
     "drupal/google_analytics_reports": "3.x-dev#2b6bb8efbc7f61ce3c1225638075aa6037b8db44",
     "drupal/login_destination": "1.x-dev#54be8b89fdc073ca40af6b9b2eeb050e0aeb7908",
+    "drupal/betterlogin": "1.x-dev#f7cf1c5c9ec5e80c6ac0ef04ed605e25495232cd",
     "drupal/ckeditor_media_embed": "1.1",
     "drupal/total_control": "2.0-alpha3",
     "drupal/anchor_link": "1.6",
diff --git a/drupal-org.make b/drupal-org.make
index ba860f32..c07b16e3 100644
--- a/drupal-org.make
+++ b/drupal-org.make
@@ -310,6 +310,11 @@ projects[login_destination][download][url] = https://git.drupal.org/project/logi
 projects[login_destination][download][revision] = 54be8b89fdc073ca40af6b9b2eeb050e0aeb7908
 projects[login_destination][download][branch] = 8.x-1.x
 
+projects[betterlogin][type] = module
+projects[betterlogin][download][url] = https://git.drupal.org/project/betterlogin.git
+projects[betterlogin][download][revision] = f7cf1c5c9ec5e80c6ac0ef04ed605e25495232cd
+projects[betterlogin][download][branch] = 8.x-1.x
+
 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_core/varbase_core.module b/modules/varbase_features/varbase_core/varbase_core.module
index 8b8fee1b..20364254 100644
--- a/modules/varbase_features/varbase_core/varbase_core.module
+++ b/modules/varbase_features/varbase_core/varbase_core.module
@@ -32,3 +32,11 @@ function varbase_core_form_node_form_alter(&$form, $form_state) {
     $form['ds_switch_view_mode']['#weight'] = 101;
   }
 }
+
+/**
+ * Implements hook_template_preprocess_default_variables_alter().
+ */
+function varbase_core_template_preprocess_default_variables_alter(&$variables) {
+  $user_settings_config = \Drupal::config('user.settings');
+  $variables['user_settings_register_admin_only'] = $user_settings_config->get('register') == 'admin_only' ? 1 : 0;
+}
diff --git a/tests/features/varbase/step2-apply-tests/02-user-management/02-01-request-new-password.feature b/tests/features/varbase/step2-apply-tests/02-user-management/02-01-request-new-password.feature
index c4d8f6a6..5d59f6e7 100644
--- a/tests/features/varbase/step2-apply-tests/02-user-management/02-01-request-new-password.feature
+++ b/tests/features/varbase/step2-apply-tests/02-user-management/02-01-request-new-password.feature
@@ -10,7 +10,7 @@ So that I can reset my password for the account
   Scenario: Check that an anonymous user can reset his/her password.
      When I go to "/user/login"
       And I wait
-     Then I should see "Reset your password"
+     Then I should see "Forgot your password?"
 
   @local @development @staging @production
   Scenario: Verify that the system cannot send an email to non-existing users/emails.
diff --git a/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.libraries.yml b/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.libraries.yml
index 14d3a586..b4f0d4b0 100644
--- a/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.libraries.yml
+++ b/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.libraries.yml
@@ -28,7 +28,13 @@ vbp-colors:
   css:
     theme:
       css/theme/vbp-colors.theme.css: {}
-    
+
+# VARTHEME_SUBTHEME better login theme.
+#betterlogin:
+#  css:
+#    theme:
+#      css/theme/betterlogin.theme.css: {}
+
 # VARTHEME_SUBTHEME Vartheme styles library.
 vartheme-styles:
   css:
diff --git a/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.starterkit.yml b/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.starterkit.yml
index 94f64e1e..aac81358 100644
--- a/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.starterkit.yml
+++ b/themes/vartheme/VARTHEME_SUBTHEME/VARTHEME_SUBTHEME.starterkit.yml
@@ -34,6 +34,9 @@ libraries:
   
 # VARTHEME_SUBTHEME Varbase Bootstrap Paragraphs colors theme.
   - VARTHEME_SUBTHEME/vbp-colors
+  
+# VARTHEME_SUBTHEME Better Login theme.
+#  - VARTHEME_SUBTHEME/betterlogin
 
 # OPTIONALLY: You can choose to remove Vartheme base theme stylesheets and/or
 # Javascript files.
@@ -46,7 +49,7 @@ libraries-override:
   vartheme/bootstrap-scripts: false
   vartheme/global-styles: false
   vartheme/global-scripts: false
-  
+
 # Comment lines to use (RTL) libraries from vartheme.
   vartheme/bootstrap-styles-rtl: false
   vartheme/global-styles-rtl: false
@@ -57,6 +60,7 @@ libraries-override:
 # VARTHEME_SUBTHEME Varbase Bootstrap Paragraphs colors theme.
   varbase_bootstrap_paragraphs/vbp-colors: VARTHEME_SUBTHEME/vbp-colors
   vartheme/vbp-colors: VARTHEME_SUBTHEME/vbp-colors
+#  vartheme/betterlogin: VARTHEME_SUBTHEME/betterlogin
   
 # Uncomment lines to replace, exclude css and js files from vartheme.
 # You will need to copy less/css files from Vartheme to use theme for the
diff --git a/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css b/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css
new file mode 100644
index 00000000..bb21e66e
--- /dev/null
+++ b/themes/vartheme/VARTHEME_SUBTHEME/css/theme/betterlogin.theme.css
@@ -0,0 +1,27 @@
+#auth-box {
+  padding: 50px 0 0;
+}
+#auth-box h1#the-logo {
+  text-align: center;
+  margin: 0;
+  padding: 0 0 25px;
+}
+#auth-box h2.title {
+  margin: 0;
+  padding: 0 0 15px;
+  font-size: 2em;
+}
+#auth-box #middle-part {
+  border-radius: 3px;
+  background: #fff;
+  padding: 15px;
+  overflow: hidden;
+  box-shadow: 0 0 3px 1px #ccc;
+}
+#auth-box .back-link {
+  padding: 15px 0 0;
+}
+#auth-box #bottom-part {
+  font-size: 13px;
+  padding: 15px 0 0;
+}
diff --git a/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less b/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less
new file mode 100644
index 00000000..07d56584
--- /dev/null
+++ b/themes/vartheme/VARTHEME_SUBTHEME/less/theme/betterlogin.theme.less
@@ -0,0 +1,40 @@
+// VARTHEME-SUBTHEME Better login styling.
+// -----------------------------------------------------------------------------
+@import "../../bootstrap/less/variables.less";  // Bootstrap variables.
+@import "../../bootstrap/less/mixins.less";     // Bootstrap mixins.
+@import "../variables.less";                    // VARTHEME-SUBTHEME variables.
+@import "../mixins.less";                       // VARTHEME-SUBTHEME mixins.
+// -----------------------------------------------------------------------------
+
+#auth-box {
+  padding: @navbar-height 0 0;
+
+  h1#the-logo {
+    text-align: center;
+    margin: 0;
+    padding: 0 0 25px;
+  }
+
+  h2.title {
+    margin: 0;
+    padding: 0 0 15px;
+    font-size: 2em;
+  }
+
+  #middle-part {
+    border-radius: 3px;
+    background: @body-bg;
+    padding: 15px;
+    overflow: hidden;
+    box-shadow: 0 0 3px 1px @popover-fallback-border-color;
+  }
+
+  .back-link {
+    padding: 15px 0 0;
+  }
+
+  #bottom-part {
+    font-size: 13px;
+    padding: 15px 0 0;
+  }
+}
diff --git a/themes/vartheme/css/theme/betterlogin.theme.css b/themes/vartheme/css/theme/betterlogin.theme.css
new file mode 100644
index 00000000..bb21e66e
--- /dev/null
+++ b/themes/vartheme/css/theme/betterlogin.theme.css
@@ -0,0 +1,27 @@
+#auth-box {
+  padding: 50px 0 0;
+}
+#auth-box h1#the-logo {
+  text-align: center;
+  margin: 0;
+  padding: 0 0 25px;
+}
+#auth-box h2.title {
+  margin: 0;
+  padding: 0 0 15px;
+  font-size: 2em;
+}
+#auth-box #middle-part {
+  border-radius: 3px;
+  background: #fff;
+  padding: 15px;
+  overflow: hidden;
+  box-shadow: 0 0 3px 1px #ccc;
+}
+#auth-box .back-link {
+  padding: 15px 0 0;
+}
+#auth-box #bottom-part {
+  font-size: 13px;
+  padding: 15px 0 0;
+}
diff --git a/themes/vartheme/less/theme/betterlogin.theme.less b/themes/vartheme/less/theme/betterlogin.theme.less
new file mode 100644
index 00000000..50d15b2f
--- /dev/null
+++ b/themes/vartheme/less/theme/betterlogin.theme.less
@@ -0,0 +1,40 @@
+// Vartheme Better Login styling.
+// -----------------------------------------------------------------------------
+@import "../../bootstrap/less/variables.less";  // Bootstrap variables.
+@import "../../bootstrap/less/mixins.less";     // Bootstrap mixins.
+@import "../variables.less";                    // Vartheme variables.
+@import "../mixins.less";                       // Vartheme mixins.
+// -----------------------------------------------------------------------------
+
+#auth-box {
+  padding: @navbar-height 0 0;
+
+  h1#the-logo {
+    text-align: center;
+    margin: 0;
+    padding: 0 0 25px;
+  }
+
+  h2.title {
+    margin: 0;
+    padding: 0 0 15px;
+    font-size: 2em;
+  }
+
+  #middle-part {
+    border-radius: 3px;
+    background: @body-bg;
+    padding: 15px;
+    overflow: hidden;
+    box-shadow: 0 0 3px 1px @popover-fallback-border-color;
+  }
+
+  .back-link {
+    padding: 15px 0 0;
+  }
+
+  #bottom-part {
+    font-size: 13px;
+    padding: 15px 0 0;
+  }
+}
diff --git a/themes/vartheme/templates/betterlogin/page--user--login.html.twig b/themes/vartheme/templates/betterlogin/page--user--login.html.twig
new file mode 100644
index 00000000..2aa9a020
--- /dev/null
+++ b/themes/vartheme/templates/betterlogin/page--user--login.html.twig
@@ -0,0 +1,34 @@
+{# Main #}
+{% block main %}
+<div role="main" class="main-container container">
+  <div class="row">
+    <div id="auth-box" class="login col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
+      <div id="top-part">
+        <h1 id="the-logo">
+          <a href="{{ url('<front>') }}">
+            <img src="{{ logo }}" alt="{{ site_name }}" />
+          </a>
+        </h1>
+      </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 }}
+      </div>
+      <div id="bottom-part">
+        <div class="password-link">
+          <a href="{{ path('user.pass') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Forgot your password?'|t }}</a>
+        </div>
+      {% if not logged_in and not user_settings_register_admin_only %}
+        <div class="register-link">
+          <a href="{{ path('user.register') }}"><span class="icon glyphicon glyphicon-user" aria-hidden="true"></span> {{ 'Register a new account'|t }}</a>
+        </div>
+      {% endif %}
+        <div class="back-link">
+          <a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }}  {{ site_name }}</a>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+{% endblock main %}
diff --git a/themes/vartheme/templates/betterlogin/page--user--password.html.twig b/themes/vartheme/templates/betterlogin/page--user--password.html.twig
new file mode 100644
index 00000000..9b6dd6bf
--- /dev/null
+++ b/themes/vartheme/templates/betterlogin/page--user--password.html.twig
@@ -0,0 +1,36 @@
+{# Main #}
+{% block main %}
+<div role="main" class="main-container container">
+  <div class="row">
+    <div id="auth-box" class="login col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
+      <div id="top-part">
+        <h1 id="the-logo">
+          <a href="{{ url('<front>') }}">
+            <img src="{{ logo }}" alt="{{ site_name }}" />
+          </a>
+        </h1>
+      </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 }}
+      </div>
+      <div id="bottom-part">
+      {% if not logged_in %}
+        <div class="login-link">
+          <a href="{{ path('user.login') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Login'|t }}</a>
+        </div>
+      {% endif %}
+      {% if not logged_in and not user_settings_register_admin_only %}
+        <div class="register-link">
+          <a href="{{ path('user.register') }}"><span class="icon glyphicon glyphicon-user" aria-hidden="true"></span> {{ 'Register a new account'|t }}</a>
+        </div>
+      {% endif %}
+        <div class="back-link">
+          <a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }}  {{ site_name }}</a>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+{% endblock main %}
diff --git a/themes/vartheme/templates/betterlogin/page--user--register.html.twig b/themes/vartheme/templates/betterlogin/page--user--register.html.twig
new file mode 100644
index 00000000..9319faba
--- /dev/null
+++ b/themes/vartheme/templates/betterlogin/page--user--register.html.twig
@@ -0,0 +1,31 @@
+{# Main #}
+{% block main %}
+<div role="main" class="main-container container">
+  <div class="row">
+    <div id="auth-box" class="login col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
+      <div id="top-part">
+        <h1 id="the-logo">
+          <a href="{{ url('<front>') }}">
+            <img src="{{ logo }}" alt="{{ site_name }}" />
+          </a>
+        </h1>
+      </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 }}
+      </div>
+      <div id="bottom-part">
+      {% if not logged_in %}
+        <div class="login-link">
+          <a href="{{ path('user.login') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Login'|t }}</a>
+        </div>
+      {% endif %}
+        <div class="back-link">
+          <a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }}  {{ site_name }}</a>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+{% endblock main %}
diff --git a/themes/vartheme/templates/betterlogin/page--user--reset.html.twig b/themes/vartheme/templates/betterlogin/page--user--reset.html.twig
new file mode 100644
index 00000000..9b6dd6bf
--- /dev/null
+++ b/themes/vartheme/templates/betterlogin/page--user--reset.html.twig
@@ -0,0 +1,36 @@
+{# Main #}
+{% block main %}
+<div role="main" class="main-container container">
+  <div class="row">
+    <div id="auth-box" class="login col-xs-10 col-xs-offset-1 col-sm-4 col-sm-offset-4">
+      <div id="top-part">
+        <h1 id="the-logo">
+          <a href="{{ url('<front>') }}">
+            <img src="{{ logo }}" alt="{{ site_name }}" />
+          </a>
+        </h1>
+      </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 }}
+      </div>
+      <div id="bottom-part">
+      {% if not logged_in %}
+        <div class="login-link">
+          <a href="{{ path('user.login') }}"><span class="icon glyphicon glyphicon-log-in" aria-hidden="true"></span> {{ 'Login'|t }}</a>
+        </div>
+      {% endif %}
+      {% if not logged_in and not user_settings_register_admin_only %}
+        <div class="register-link">
+          <a href="{{ path('user.register') }}"><span class="icon glyphicon glyphicon-user" aria-hidden="true"></span> {{ 'Register a new account'|t }}</a>
+        </div>
+      {% endif %}
+        <div class="back-link">
+          <a href="{{ url('<front>') }}"><span class="icon glyphicon glyphicon-home" aria-hidden="true"></span> {{ 'Back to'|t }}  {{ site_name }}</a>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
+{% endblock main %}
diff --git a/themes/vartheme/vartheme.info.yml b/themes/vartheme/vartheme.info.yml
index edf05bbb..583494ad 100755
--- a/themes/vartheme/vartheme.info.yml
+++ b/themes/vartheme/vartheme.info.yml
@@ -24,7 +24,7 @@ libraries:
 # Bootstrap styles and scripts libraries.
   - vartheme/bootstrap-styles
   - vartheme/bootstrap-scripts
-  
+
 # Boostrap component libraries.
   - vartheme/ajax
   - vartheme/alert
@@ -49,7 +49,7 @@ libraries:
   - vartheme/edge2edge
   - vartheme/bootstrap-print
   - vartheme/bootstrap-no-spacing
-  
+
 # Vartheme general global styles and scripts libraries.
   - vartheme/global-styles
   - vartheme/global-scripts
@@ -57,9 +57,13 @@ libraries:
 # Vartheme Varbase Bootstrap Paragraphs colors theme.
   - vartheme/vbp-colors
 
+# Vartheme Better Login theme.
+  - vartheme/betterlogin
+
 # Vartheme Varbase Bootstrap Paragraphs colors theme.
 libraries-override:
   varbase_bootstrap_paragraphs/vbp-colors: vartheme/vbp-colors
+  betterlogin/betterlogin_css: vartheme/betterlogin
 #  bootstrap_library/bootstrap-cdn: false
 #  bootstrap_library/bootstrap: false
 #  bootstrap_library/bootstrap-dev: false
diff --git a/themes/vartheme/vartheme.libraries.yml b/themes/vartheme/vartheme.libraries.yml
index ee8f021b..58f40461 100644
--- a/themes/vartheme/vartheme.libraries.yml
+++ b/themes/vartheme/vartheme.libraries.yml
@@ -1,5 +1,5 @@
 # Vartheme global styles library.
-global-styles: 
+global-styles:
   css:
     base:
       css/base/vartheme.base.css: {}
@@ -22,13 +22,19 @@ global-styles-rtl:
 global-scripts:
   js:
     js/script.js: {}
-    
+
 # Vartheme Varbase Bootstrap Paragraphs colors theme.
 vbp-colors:
   css:
     theme:
       css/theme/vbp-colors.theme.css: {}
 
+# Vartheme better login theme.
+betterlogin:
+  css:
+    theme:
+      css/theme/betterlogin.theme.css: {}
+
 # Bootstrap global styles library.
 bootstrap-styles:
   css:
@@ -39,7 +45,7 @@ bootstrap-styles-rtl:
   css:
     base:
       css/rtl/base/bootstrap-rtl.base.css: {}
-      
+
 # Bootstrap global scripts library.
 bootstrap-scripts:
   js:
diff --git a/varbase.info.yml b/varbase.info.yml
index 82552326..c17e2c76 100755
--- a/varbase.info.yml
+++ b/varbase.info.yml
@@ -113,6 +113,7 @@ dependencies:
   - autocomplete_deluxe
   - link_attributes
   - login_destination
+  - betterlogin
   - ckeditor_media_embed
 
 themes:
diff --git a/varbase.install b/varbase.install
index 9d672248..2131fa3c 100644
--- a/varbase.install
+++ b/varbase.install
@@ -542,3 +542,12 @@ function varbase_update_8042() {
     \Drupal::service('module_installer')->install(['settings_tray'], FALSE);
   }
 }
+
+/**
+ * Enable Better Login module.
+ */
+function varbase_update_8043() {
+  if (!\Drupal::moduleHandler()->moduleExists('betterlogin')) {
+    \Drupal::service('module_installer')->install(['betterlogin'], FALSE);
+  }
+}
-- 
GitLab