Skip to content

Commit

Permalink
(bug) unable to switch auth provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Feb 2, 2024
1 parent e27fd10 commit 12d03e2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/tasks/fablab/auth.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ namespace :fablab do
namespace :auth do
desc 'switch the active authentication provider'
task :switch_provider, [:provider] => :environment do |_task, args|
providers = AuthProvider.all.inject('') { |str, item| "#{str}#{item[:name]}, " }
unless args.provider
puts "\e[0;31mERROR\e[0m: You must pass a provider name to activate. Available providers are: #{providers[0..-3]}"
next
end

if AuthProvider.find_by(name: args.provider).nil?
puts "\e[0;31mERROR\e[0m: the provider '#{args.provider}' does not exists. Available providers are: #{providers[0..-3]}"
next
end

if AuthProvider.active.name == args.provider
puts "\e[0;31mERROR\e[0m: the provider '#{args.provider}' is already enabled"
next
end

# disable previous provider
prev_prev = AuthProvider.previous
Expand All @@ -13,7 +28,7 @@ namespace :fablab do
AuthProvider.active.update(status: 'previous') unless AuthProvider.active.name == 'DatabaseProvider::SimpleAuthProvider'

# enable given provider
AuthProvider.find_by(name: 'FabManager').update(status: 'active')
AuthProvider.find_by(name: args.provider).update(status: 'active')

# migrate the current users.
if AuthProvider.active.providable_type == DatabaseProvider.name
Expand Down

0 comments on commit 12d03e2

Please sign in to comment.