diff --git a/social_auth.module b/social_auth.module
index 8fdf8cb..7503d00 100755
--- a/social_auth.module
+++ b/social_auth.module
@@ -6,6 +6,8 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Render\Markup;
+use Drupal\Core\Url;
/**
* Implements hook_theme().
@@ -23,9 +25,26 @@ function social_auth_theme() {
*/
function social_auth_preprocess_login_with(&$variables) {
$request = \Drupal::request();
- if ($request->query->has('destination')) {
- $variables['destination'] = $request->query->get('destination');
+ $destination = $request->query->get('destination');
+ foreach ($variables['social_networks'] as $network => &$value) {
+ $url = Url::fromRoute($value['route'], ['absolute' => TRUE]);
+ if ($destination) {
+ $url->setOption('query', ['destination' => $destination]);
+ }
+ // \Drupal\Core\Render\Markup is internal, however is used liberally
+ // throughout core in a similar context.
+ $image = Markup::create('
');
+ $value['link'] = [
+ '#type' => 'link',
+ '#cache' => [
+ 'contexts' => ['url.query_args:destination'],
+ ],
+ '#url' => $url,
+ '#title' => $image,
+ '#attributes' => ['class' => ['social-auth', 'auth-link']],
+ ];
}
+ // Deprecated but maintained here in case themers were using this value.
$variables['base_path'] = base_path();
}
diff --git a/src/SettingsTrait.php b/src/SettingsTrait.php
index 6b1d54a..b8c3740 100644
--- a/src/SettingsTrait.php
+++ b/src/SettingsTrait.php
@@ -133,7 +133,6 @@ trait SettingsTrait {
* Post Login Path to which the user would be redirected after login.
*/
protected function getPostLoginRedirection() {
-
// Gets destination parameter previously stored in session.
$destination = $this->dataHandler->get('login_destination');
// If there was a destination parameter.
@@ -141,8 +140,7 @@ trait SettingsTrait {
// Deletes the session key.
$this->dataHandler->set('login_destination', NULL);
- // Redirects to the defined destination path.
- return new RedirectResponse(Url::fromUri('base:' . $destination)->toString());
+ return new RedirectResponse(Url::fromUserInput($destination)->toString());
}
$post_login = $this->configFactory->get('social_auth.settings')->get('post_login');
@@ -152,7 +150,7 @@ trait SettingsTrait {
return new RedirectResponse(Url::fromUserInput($post_login)->toString());
}
- return new RedirectResponse(Url::fromUri('base:' . $destination)->toString());
+ return new RedirectResponse(Url::fromRoute('')->toString());
}
}
diff --git a/templates/login-with.html.twig b/templates/login-with.html.twig
index 8270e00..d5ecd67 100755
--- a/templates/login-with.html.twig
+++ b/templates/login-with.html.twig
@@ -1,13 +1,5 @@
-{% set module = 'social-auth' %}
-
{{ attach_library('social_auth/auth-icons') }}
{% for social_network in social_networks %}
- {% if destination %}
-
- {% else %}
-
- {% endif %}
-
-
+ {{ social_network.link }}
{% endfor %}