forked from External/greenlight
GRN2-155: Begin preparing for removal of Twitter accounts (#615)
* Add twitter deprecation message * Fix rspec test * Extract room switch to its own method * update method name
This commit is contained in:
committed by
Jesus Federico
parent
a3158b5872
commit
40b05b1626
@ -33,7 +33,11 @@ module ApplicationHelper
|
||||
|
||||
# Determines which providers can show a login button in the login modal.
|
||||
def iconset_providers
|
||||
configured_providers & [:google, :twitter, :microsoft_office365]
|
||||
providers = configured_providers & [:google, :twitter, :microsoft_office365]
|
||||
|
||||
providers.delete(:twitter) if session[:old_twitter_user_id]
|
||||
|
||||
providers
|
||||
end
|
||||
|
||||
# Generates the login URL for a specific provider.
|
||||
|
@ -19,6 +19,8 @@
|
||||
module SessionsHelper
|
||||
# Logs a user into GreenLight.
|
||||
def login(user)
|
||||
migrate_twitter_user(user)
|
||||
|
||||
session[:user_id] = user.id
|
||||
|
||||
# If there are not terms, or the user has accepted them, check for email verification
|
||||
@ -97,4 +99,24 @@ module SessionsHelper
|
||||
hd_opts
|
||||
end
|
||||
end
|
||||
|
||||
def migrate_twitter_user(user)
|
||||
if !session["old_twitter_user_id"].nil? && user.provider != "twitter"
|
||||
old_user = User.find(session["old_twitter_user_id"])
|
||||
|
||||
old_user.rooms.each do |room|
|
||||
room.owner = user
|
||||
|
||||
room.name = "Old " + room.name if room.id == old_user.main_room.id
|
||||
|
||||
room.save!
|
||||
end
|
||||
|
||||
# Query for the old user again so the migrated rooms don't get deleted
|
||||
old_user.reload
|
||||
old_user.destroy!
|
||||
|
||||
session["old_twitter_user_id"] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user