Skip to content

Commit

Permalink
Merge 0a3b7f9 into 5fe5ad0
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Sep 24, 2020
2 parents 5fe5ad0 + 0a3b7f9 commit 9a3faf4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ def reset_api_key!
save
end

def active_for_authentication?
super && !deactivated
end

def destroy
update_attributes(deactivated: true) unless deactivated
end

def destroy!
update_attributes!(deactivated: true) unless deactivated
end

private
def generate_api_key
begin
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ en:
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
inactive: "Your account has been deactivated. Please contact the WhatsOpt administrator."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked."
last_attempt: "You have one more attempt before your account is locked."
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20200924122931_add_deactivated_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDeactivatedToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :deactivated, :boolean
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_06_27_210649) do
ActiveRecord::Schema.define(version: 2020_09_24_122931) do

create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -285,6 +285,7 @@
t.datetime "updated_at", null: false
t.string "api_key"
t.text "settings"
t.boolean "deactivated"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Expand Down

0 comments on commit 9a3faf4

Please sign in to comment.