Skip to content

Commit

Permalink
11403: remove unused user api_key
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Nov 29, 2023
1 parent 47eb7f0 commit f9dd5e5
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 68 deletions.
6 changes: 0 additions & 6 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ def export
end
end

def regenerate_api_key
@user.regenerate_api_key
@user.save(validate: false)
render(json: {value: @user.api_key})
end

def regenerate_sms_auth_code
@user.regenerate_sms_auth_code
@user.save(validate: false)
Expand Down
1 change: 0 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# id :uuid not null, primary key
# active :boolean default(TRUE), not null
# admin :boolean default(FALSE), not null
# api_key :string(255)
# birth_year :integer
# crypted_password :string(255) not null
# current_login_at :datetime
Expand Down
1 change: 0 additions & 1 deletion app/serializers/user_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# id :uuid not null, primary key
# active :boolean default(TRUE), not null
# admin :boolean default(FALSE), not null
# api_key :string(255)
# birth_year :integer
# crypted_password :string(255) not null
# current_login_at :datetime
Expand Down
3 changes: 0 additions & 3 deletions app/views/users/form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
<%= f.field(:password_confirmation, type: :password) %>
</div>
<% end %>
<% if !@user.new_record? && can?(:regenerate_api_key, @user) %>
<%= f.regenerable_field(:api_key, confirm: t("setting.api_key_warning")) %>
<% end %>
<% if !@user.new_record? && can?(:regenerate_sms_auth_code, @user) %>
<%= f.regenerable_field(:sms_auth_code, confirm: t("setting.sms_auth_code_warning")) %>
<% end %>
Expand Down
3 changes: 0 additions & 3 deletions config/locales/en/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,6 @@ en:
change_api_key: "Change API Key"
override_code_warning: "Note that the new override code will not work with forms that have already been downloaded. You should record the existing code if this is a problem. Are you sure you want to regenerate the code?"
sms_token_warning: "Note that this will invalidate the previous SMS token for this mission. All incoming SMSes will be rejected until your SMS gateway settings are updated accordingly. Are you sure you want to regenerate the token?"
api_key_warning: "Note that this will invalidate the previous API key for this user. Are you sure you want to regenerate the key?"
sms_auth_code_warning: "Note that this will invalidate the previous SMS auth code for this user. Are you sure you want to regenerate the code?"
using_incoming_sms_token: "How do I use this?"
headings:
Expand Down Expand Up @@ -2373,8 +2372,6 @@ en:
user:
add_assignment: "Add Assignment"
api_key:
regenerate: "Regenerate"
back_to_index: "Back to Users List"
bulk_destroy_confirm:
zero: "Are you sure you want to delete zero users?"
Expand Down
22 changes: 13 additions & 9 deletions db/migrate/20231129192037_remove_api_v1_columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
class RemoveAPIV1Columns < ActiveRecord::Migration[6.1]
def up
drop_table :whitelistings

remove_column :users, :api_key
end

def down
# create_table "whitelistings", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
# t.uuid "user_id"
# t.uuid "whitelistable_id"
# t.string "whitelistable_type", limit: 255
# t.index ["user_id"], name: "index_whitelistings_on_user_id"
# t.index ["whitelistable_id"], name: "index_whitelistings_on_whitelistable_id"
# end
create_table :whitelistings, id: :uuid, default: -> { "uuid_generate_v4()" } do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "user_id"
t.uuid "whitelistable_id"
t.string "whitelistable_type", limit: 255
t.index ["user_id"], name: "index_whitelistings_on_user_id"
t.index ["whitelistable_id"], name: "index_whitelistings_on_whitelistable_id"
end

add_column :users, :api_key, :string, limit: 255
end
end
1 change: 0 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@
create_table "users", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t|
t.boolean "active", default: true, null: false
t.boolean "admin", default: false, null: false
t.string "api_key", limit: 255
t.integer "birth_year"
t.datetime "created_at", null: false
t.string "crypted_password", limit: 255, null: false
Expand Down
Binary file modified docs/erd.pdf
Binary file not shown.
1 change: 0 additions & 1 deletion spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# id :uuid not null, primary key
# active :boolean default(TRUE), not null
# admin :boolean default(FALSE), not null
# api_key :string(255)
# birth_year :integer
# crypted_password :string(255) not null
# current_login_at :datetime
Expand Down
1 change: 0 additions & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# id :uuid not null, primary key
# active :boolean default(TRUE), not null
# admin :boolean default(FALSE), not null
# api_key :string(255)
# birth_year :integer
# crypted_password :string(255) not null
# current_login_at :datetime
Expand Down
30 changes: 0 additions & 30 deletions spec/support/contexts/api_context.rb

This file was deleted.

12 changes: 0 additions & 12 deletions spec/support/helpers/request_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ def logout
follow_redirect!
end

def do_api_request(endpoint, params = {})
params[:user] ||= @api_user
params[:mission_name] ||= @mission.compact_name

path_args = [{mission_name: params[:mission_name]}]
path_args.unshift(params[:obj]) if params[:obj]
path = send("api_v1_#{endpoint}_path", *path_args)

get(path, params: params[:params],
headers: {"HTTP_AUTHORIZATION" => "Token token=#{params[:user].api_key}"})
end

# Needed for older request specs, maybe related to assert_select.
# See http://blog.cynthiakiser.com/blog/page/5/
def document_root_element
Expand Down

0 comments on commit f9dd5e5

Please sign in to comment.