Last active
December 10, 2020 10:03
-
-
Save samuels410/9a493a89373d1985f631ce8abed0781b to your computer and use it in GitHub Desktop.
OTP reset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
otp_users = [] | |
no_login_users =[] | |
account = Account.find(70) | |
courses = account.courses | |
course_ids = courses.collect(&:id) | |
enrollments = Enrollment.where(course_id: course_ids,workflow_state: ["inactive","active"]) | |
user_ids = enrollments.collect(&:user_id).uniq | |
users = User.where(id: user_ids) | |
users.each do |user| | |
if user.otp_communication_channel_id || user.otp_secret_key_salt | |
user.otp_secret_key = nil | |
user.otp_communication_channel = nil | |
user.save! | |
user.one_time_passwords.scope.delete_all | |
otp_users << user | |
else | |
no_login_users << user | |
end | |
end | |
puts "#{account.name} OTP details : " | |
puts "Total active inactive students count : #{user_ids.size}" | |
puts "Users had otp : #{otp_users.size}" | |
puts "Users not logged in after we enabled OTP/Never logged in : #{no_login_users.size}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment