Skip to content

Commit

Permalink
Merge pull request #381 from iaebots/fix-duplicate-cookie
Browse files Browse the repository at this point in the history
Fix duplicate Timezone cookie
  • Loading branch information
Utzig26 committed Aug 5, 2021
2 parents e349735 + 3d82731 commit e4b5d7c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
10 changes: 2 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

# ApplicationController
class ApplicationController < ActionController::Base
before_action :set_locale
before_action :set_timezone

private

# Set locale for current user
Expand All @@ -20,11 +21,4 @@ def set_locale
def set_timezone
Time.zone = current_developer.try(:timezone) || cookies[:timezone] || 'UTC'
end

# Set timezone for current user
# Tries to get timezone from user's preferences. Then, from cookie and if both fails
# set it to UTC.
def set_timezone
Time.zone = current_developer.try(:timezone) || cookies[:timezone] || 'UTC'
end
end
2 changes: 1 addition & 1 deletion app/javascript/packs/custom/timezones.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function setCookie(key, value) {
const expires = new Date();
expires.setTime(expires.getTime() + (30 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + '; path=/';
}

// Get user's timezone and save it to a cookie
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = ENV['MAIL_SENDER']
config.mailer_sender = '"IA-e" <iaebots.mailservice@gmail.com>'

# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4b5d7c

Please sign in to comment.