From 7dc419a409b8e127ffcf622c5d68fde564f5828b Mon Sep 17 00:00:00 2001 From: Andrei Kaleshka Date: Thu, 1 Feb 2024 14:12:44 +0100 Subject: [PATCH] do not show social login buttons for webview --- app/views/devise/registrations/new.html.slim | 44 +++++++++++++------- app/views/devise/sessions/new.html.slim | 44 +++++++++++++------- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/app/views/devise/registrations/new.html.slim b/app/views/devise/registrations/new.html.slim index dab86d3..a892248 100644 --- a/app/views/devise/registrations/new.html.slim +++ b/app/views/devise/registrations/new.html.slim @@ -8,22 +8,23 @@ h2.title.is-4.is-light = t('.sign_up') h2.title.font-frank-ruhl-libre Get Started for free - if Devise.omniauth_providers.include?(:google_oauth2) - .field - .buttons.is-centered - = button_to user_google_oauth2_omniauth_authorize_path, method: :post, class: 'button is-outlined', id: 'google-button' do - span - figure.image.is-24x24 - = image_tag('google.svg', class:'is-rounded', alt: 'G') - |   Google - = button_to user_facebook_omniauth_authorize_path, method: :post, class: 'button is-outlined', id: 'facebook-button' do - span - figure.image.is-24x24 - = image_tag('facebook.svg', class:'is-rounded', alt: 'F') - |   Facebook - br - p.text-divider - | Or continue with - br + .social-login-block + .field + .buttons.is-centered + = button_to user_google_oauth2_omniauth_authorize_path, method: :post, class: 'button is-outlined', id: 'google-button' do + span + figure.image.is-24x24 + = image_tag('google.svg', class:'is-rounded', alt: 'G') + |   Google + = button_to user_facebook_omniauth_authorize_path, method: :post, class: 'button is-outlined', id: 'facebook-button' do + span + figure.image.is-24x24 + = image_tag('facebook.svg', class:'is-rounded', alt: 'F') + |   Facebook + br + p.text-divider + | Or continue with + br = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = render "devise/shared/error_messages", resource: resource .field @@ -62,3 +63,14 @@ .column.has-background-image figure.image.is-coins = image_tag('coins.svg') + +javascript: + document.addEventListener('turbolinks:load', function() { + const isWebView = navigator.userAgent.match(/(Android|iPhone|iPad|iPod)(.*wv)/gi) !== null; + + console.log(isWebView) + + if (isWebView) { + document.querySelector('.social-login-block').style.display = 'none'; + } + }); diff --git a/app/views/devise/sessions/new.html.slim b/app/views/devise/sessions/new.html.slim index d97823a..fe05299 100644 --- a/app/views/devise/sessions/new.html.slim +++ b/app/views/devise/sessions/new.html.slim @@ -8,22 +8,23 @@ h2.title.is-4.is-light = t('.login') h2.title.font-frank-ruhl-libre Login to your account - if Devise.omniauth_providers.include?(:google_oauth2) - .field - .buttons.is-centered - = link_to user_google_oauth2_omniauth_authorize_path, method: :post, class: 'button is-outlined' do - span - figure.image.is-24x24 - = image_tag('google.svg', class:'is-rounded', alt: 'G') - |   Google - = link_to user_facebook_omniauth_authorize_path, method: :post, class: 'button is-outlined' do - span - figure.image.is-24x24 - = image_tag('facebook.svg', class:'is-rounded', alt: 'F') - |   Facebook - br - p.text-divider - | Or continue with - br + .social-login-block + .field + .buttons.is-centered + = link_to user_google_oauth2_omniauth_authorize_path, method: :post, class: 'button is-outlined' do + span + figure.image.is-24x24 + = image_tag('google.svg', class:'is-rounded', alt: 'G') + |   Google + = link_to user_facebook_omniauth_authorize_path, method: :post, class: 'button is-outlined' do + span + figure.image.is-24x24 + = image_tag('facebook.svg', class:'is-rounded', alt: 'F') + |   Facebook + br + p.text-divider + | Or continue with + br = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| .field = f.label :email @@ -57,3 +58,14 @@ .column.has-background-image figure.image.is-coins = image_tag('coins.svg') + +javascript: + document.addEventListener('turbolinks:load', function() { + const isWebView = navigator.userAgent.match(/(Android|iPhone|iPad|iPod)(.*wv)/gi) !== null; + + console.log(isWebView) + + if (isWebView) { + document.querySelector('.social-login-block').style.display = 'none'; + } + });