Skip to content

Commit d1e6350

Browse files
committed
add unconfirmed access env var to gala dev and staging to show/hide
google oauth button
1 parent 313337e commit d1e6350

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

app/views/application/_footer.html.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
target: '_blank', rel: 'noopener noreferrer'
1010
= link_to 'Open Source', 'https://github.com/galahq/gala',
1111
target: '_blank', rel: 'noopener noreferrer'
12-
%a{ href: "https://github.com/galahq/gala/releases/tag/#{ENV['RELEASE']}" }
13-
= ENV['RELEASE']
12+
- if ENV['RELEASE'].present?
13+
%a.footer__release{ href: "https://github.com/galahq/gala/releases/tag/#{ENV['RELEASE']}" }
14+
= ENV['RELEASE']

app/views/devise/registrations/new.html.haml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
autocomplete: "new-password"
3434

3535
= f.submit t('.sign_up'), class: %w[pt-intent-primary]
36-
37-
%a.pt-button.pt-icon-log-in.oauth-icon-google{role: 'button',
38-
href: omniauth_authorize_path('authentication_strategy', 'google')}
39-
= t('devise.shared.links.sign_in_with_provider', provider: 'Google')
36+
- if ENV['TEMPORARY_UNCONFIRMED_ACCESS'] == 'false'
37+
%a.pt-button.pt-icon-log-in.oauth-icon-google{role: 'button',
38+
href: omniauth_authorize_path('authentication_strategy', 'google')}
39+
= t('devise.shared.links.sign_in_with_provider', provider: 'Google')
4040

4141
= render "devise/shared/links"

app/views/devise/sessions/_sign_in.html.haml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
= f.check_box :remember_me
1717

1818
= f.submit t('devise.sessions.new.sign_in'), class: %w[pt-intent-primary]
19-
%a.pt-button.pt-icon-log-in.oauth-icon-google{ role: 'button', tabindex: '0',
20-
href: omniauth_authorize_path('authentication_strategy', 'google') }
21-
= t('devise.shared.links.sign_in_with_provider', provider: 'Google')
19+
- if ENV['TEMPORARY_UNCONFIRMED_ACCESS'] == 'false'
20+
%a.pt-button.pt-icon-log-in.oauth-icon-google{ role: 'button', tabindex: '0',
21+
href: omniauth_authorize_path('authentication_strategy', 'google') }
22+
= t('devise.shared.links.sign_in_with_provider', provider: 'Google')
2223

2324
= render "devise/shared/links"

config/application.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
# you've limited to :test, :development, or :production.
1010
Bundler.require(*Rails.groups)
1111

12+
# Set release version
13+
ENV['RELEASE'] = 'v2.2.0' # TODO: experiment doing github releases again
14+
# Determine if we're in staging environment
15+
ENV['STAGING'] = (ENV['BASE_URL']&.include?('staging')).to_s
16+
# Allow temporary unconfirmed access in staging or development
17+
ENV['TEMPORARY_UNCONFIRMED_ACCESS'] ||=
18+
(ENV['STAGING'] == 'true' || Rails.env.development?).to_s
19+
20+
puts [ENV['RELEASE'], ENV['STAGING'], ENV['TEMPORARY_UNCONFIRMED_ACCESS']].inspect
21+
1222
module Orchard
1323
class Application < Rails::Application
1424
# Settings in config/environments/* take precedence over those specified here.
@@ -26,7 +36,5 @@ class Application < Rails::Application
2636
config.middleware.use Rack::Deflater
2737
end
2838

29-
ENV['RELEASE'] = 'v2.2.0' # TODO: experiment doing github releases again
30-
3139
end
3240
end

config/initializers/devise.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@
115115
# able to access the website for two days without confirming their account,
116116
# access will be blocked just in the third day. Default is 0.days, meaning
117117
# the user cannot access the website without confirming their account.
118-
# config.allow_unconfirmed_access_for = 2.days
118+
unconfirmed = ENV['TEMPORARY_UNCONFIRMED_ACCESS'] == 'true'
119+
config.allow_unconfirmed_access_for = unconfirmed ? 7.days : 0.days
119120

120121
# A period that the user is allowed to confirm their account before their
121122
# token becomes invalid. For example, if set to 3.days, the user can confirm

0 commit comments

Comments
 (0)