Files
ubicloud/routes/account.rb
Jeremy Evans e6b7e5e879 Change rubocop TargetRubyVersion to 3.4
Disable Style/RedundantLineContinuation, as it incorrectly removes
line continutations in rhizome/host/lib/vm_setup.rb that are not
redundant.

All code changes are for _1 => it in blocks.
2025-04-26 06:51:19 +09:00

41 lines
1.4 KiB
Ruby

# frozen_string_literal: true
class Clover
hash_branch("account") do |r|
r.web do
r.get true do
r.redirect "/account/multifactor-manage"
end
r.on "login-method" do
r.get true do
@identities = current_account.identities.to_h { [it.provider, it.uid] }
view "account/login_method"
end
r.post "disconnect" do
provider, uid = typecast_params.nonempty_str(["provider", "uid"])
identities = current_account.identities
unless identities.length > (rodauth.has_password? ? 0 : 1)
flash[:error] = "You must have at least one login method"
r.redirect "/account/login-method"
end
if provider == "password"
DB[:account_password_hashes].where(id: current_account.id).delete
DB[:account_previous_password_hashes].where(account_id: current_account.id).delete
flash[:notice] = "Your password has been deleted"
elsif (identity = identities.find { it.provider == provider && it.uid == uid })
identity.destroy
flash[:notice] = "Your account has been disconnected from #{provider.capitalize}"
else
flash[:error] = "Your account already has been disconnected from #{provider.capitalize}"
end
r.redirect "/account/login-method"
end
end
end
end
end