0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

after_signup on approval fixes

Dieser Commit ist enthalten in:
Angus McLeod 2020-04-19 16:42:44 +10:00
Ursprung bffdc1f363
Commit 47722d13a3
2 geänderte Dateien mit 11 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -45,9 +45,9 @@ class CustomWizard::Wizard
@needs_categories = false
@needs_groups = false
@theme_id = attrs['theme_id']
if attrs['theme']
theme = Theme.find_by(name: attrs['theme'])
if attrs['theme'].present?
theme = ::Theme.find_by(name: attrs['theme'])
@theme_id = theme.id if theme
end
@ -210,14 +210,14 @@ class CustomWizard::Wizard
records
.sort_by { |record| record.value['permitted'].present? ? 0 : 1 }
.each do |record|
wizard = CustomWizard::Wizard.new(JSON.parse(record.value), user)
wizard = self.new(JSON.parse(record.value), user)
if wizard.permitted?
result = wizard
break
end
end
result
else
false
@ -344,7 +344,7 @@ class CustomWizard::Wizard
def self.create(wizard_id, user = nil)
if wizard = self.find(wizard_id)
CustomWizard::Wizard.new(wizard.to_h, user)
self.new(wizard.to_h, user)
else
false
end
@ -355,8 +355,8 @@ class CustomWizard::Wizard
end
def self.set_wizard_redirect(wizard_id, user)
wizard = CustomWizard::Wizard.create(wizard_id, user)
wizard = self.create(wizard_id, user)
if wizard.permitted?
user.custom_fields['redirect_to_wizard'] = wizard_id
user.save_custom_fields(true)

Datei anzeigen

@ -118,8 +118,8 @@ after_initialize do
end
on(:user_approved) do |user|
if wizard_id = CustomWizard::Wizard.after_signup(user)
CustomWizard::Wizard.set_wizard_redirect(wizard_id, user)
if wizard = CustomWizard::Wizard.after_signup(user)
CustomWizard::Wizard.set_wizard_redirect(wizard.id, user)
end
end