chore: Removing duplicate callback to create auth token (#2624)

Removed after create callback in user model to create a new access token. This is already being taken care of by AccessTokenable module.

Fixes #2620
This commit is contained in:
Mrunal Selokar
2021-07-15 15:24:38 +05:30
committed by GitHub
parent b56512eb56
commit e0535168a0
4 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
class RemoveDuplicateAccessTokensForExistingUsers < ActiveRecord::Migration[6.0]
def up
# find all models and group them on owner
grouped_tokens = AccessToken.all.group_by(&:owner)
grouped_tokens.each_value do |duplicates|
# we want to keep the latest token as it is being used in all requests
duplicates.pop
# Remaining ones are duplicates, delete them all
duplicates.each { |duplicate| AccessToken.find_by(id: duplicate).destroy }
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_07_08_140842) do
ActiveRecord::Schema.define(version: 2021_07_14_110714) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"