diff --git a/app/javascript/elements/set_timezone.js b/app/javascript/elements/set_timezone.js index be4c05e1..ab3e16bc 100644 --- a/app/javascript/elements/set_timezone.js +++ b/app/javascript/elements/set_timezone.js @@ -1,7 +1,21 @@ export default class extends HTMLElement { connectedCallback () { if (this.dataset.inputId) { - document.getElementById(this.dataset.inputId).value = Intl.DateTimeFormat().resolvedOptions().timeZone + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone + + if (this.dataset.params === 'true') { + const params = new URLSearchParams(this.input.value) + + params.set('timezone', timezone) + + this.input.value = params.toString() + } else { + this.input.value = timezone + } } } + + get input () { + return document.getElementById(this.dataset.inputId) + } } diff --git a/app/models/user.rb b/app/models/user.rb index 68112c2e..d8f23419 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -52,6 +52,7 @@ class User < ApplicationRecord belongs_to :account has_one :access_token, dependent: :destroy has_many :templates, dependent: :destroy, foreign_key: :author_id, inverse_of: :author + has_many :template_folders, dependent: :destroy, foreign_key: :author_id, inverse_of: :author has_many :user_configs, dependent: :destroy has_many :encrypted_configs, dependent: :destroy, class_name: 'EncryptedUserConfig' diff --git a/app/views/devise/registrations/show.html.erb b/app/views/devise/registrations/show.html.erb index a152729c..0b139107 100644 --- a/app/views/devise/registrations/show.html.erb +++ b/app/views/devise/registrations/show.html.erb @@ -16,7 +16,11 @@ <% end %> <% if devise_mapping.omniauthable? %> - <%= button_to button_title(title: 'Sign up with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), omniauth_authorize_path(resource_name, :google_oauth2), class: 'white-button w-full mt-4', data: { turbo: false }, method: :post %> + <%= form_for '', url: omniauth_authorize_path(resource_name, :google_oauth2), data: { turbo: false }, method: :post do |f| %> + + <%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query %> + <%= f.button button_title(title: 'Sign up with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), class: 'white-button w-full mt-4' %> + <% end %> <% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 09c51d0c..ea6d7f55 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -20,7 +20,11 @@ <% end %> <% if devise_mapping.omniauthable? %> - <%= button_to button_title(title: 'Sign in with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), omniauth_authorize_path(resource_name, :google_oauth2), class: 'white-button w-full mt-4', data: { turbo: false }, method: :post %> + <%= form_for '', url: omniauth_authorize_path(resource_name, :google_oauth2), data: { turbo: false }, method: :post do |f| %> + + <%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query %> + <%= f.button button_title(title: 'Sign in with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), class: 'white-button w-full mt-4' %> + <% end %> <% end %> <%= render 'devise/shared/links' %>