From a8c16ced73c3e851061f51d014a1bc550dc586d5 Mon Sep 17 00:00:00 2001 From: thesecretmaster Date: Sun, 2 Dec 2018 21:01:08 -0600 Subject: [PATCH] Should re-route registration to lambda --- app/helpers/authentication_helper.rb | 7 +++++-- app/views/flag_settings/index.html.erb | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/helpers/authentication_helper.rb b/app/helpers/authentication_helper.rb index 9e1cb3ae1..d3f29e8c2 100644 --- a/app/helpers/authentication_helper.rb +++ b/app/helpers/authentication_helper.rb @@ -7,8 +7,11 @@ def auth_url(scope, redirect_uri) end def write_auth_url - config = AppConfig['stack_exchange'] - auth_url('write_access,no_expiry', config['redirect_uri']) + config = AppConfig['token_store'] + state = Rails.cache.fetch("token_migration_state/#{current_user.id}", expires_in: 30.minutes) do + SecureRandom.hex(10) + end + "#{config['host']}/auth?state=#{state}" end def identify_auth_url diff --git a/app/views/flag_settings/index.html.erb b/app/views/flag_settings/index.html.erb index b048b7168..848dd9e70 100644 --- a/app/views/flag_settings/index.html.erb +++ b/app/views/flag_settings/index.html.erb @@ -7,7 +7,7 @@ Name Value - <% if user_signed_in? and current_user.has_role? :admin %> + <% if user_signed_in? && current_user.has_role? :admin %> <% end %> @@ -18,7 +18,7 @@ <%= flag_setting.name.humanize %> (<%= flag_setting.name %>) <%= flag_setting.value %> - <% if user_signed_in? and current_user.has_role? :admin %> + <% if user_signed_in? && current_user.has_role? :admin %> <%= link_to 'Edit', edit_flag_setting_path(flag_setting) %> <% end %> @@ -28,6 +28,6 @@
-<% if user_signed_in? and current_user.has_role? :admin %> +<% if user_signed_in? && current_user.has_role? :admin %> <%= link_to 'New Flag Setting', new_flag_setting_path %> <% end %>