Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
after_signup on approval fixes
Dieser Commit ist enthalten in:
Ursprung
bffdc1f363
Commit
47722d13a3
2 geänderte Dateien mit 11 neuen und 11 gelöschten Zeilen
|
@ -46,8 +46,8 @@ class CustomWizard::Wizard
|
||||||
@needs_groups = false
|
@needs_groups = false
|
||||||
@theme_id = attrs['theme_id']
|
@theme_id = attrs['theme_id']
|
||||||
|
|
||||||
if attrs['theme']
|
if attrs['theme'].present?
|
||||||
theme = Theme.find_by(name: attrs['theme'])
|
theme = ::Theme.find_by(name: attrs['theme'])
|
||||||
@theme_id = theme.id if theme
|
@theme_id = theme.id if theme
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class CustomWizard::Wizard
|
||||||
records
|
records
|
||||||
.sort_by { |record| record.value['permitted'].present? ? 0 : 1 }
|
.sort_by { |record| record.value['permitted'].present? ? 0 : 1 }
|
||||||
.each do |record|
|
.each do |record|
|
||||||
wizard = CustomWizard::Wizard.new(JSON.parse(record.value), user)
|
wizard = self.new(JSON.parse(record.value), user)
|
||||||
|
|
||||||
if wizard.permitted?
|
if wizard.permitted?
|
||||||
result = wizard
|
result = wizard
|
||||||
|
@ -344,7 +344,7 @@ class CustomWizard::Wizard
|
||||||
|
|
||||||
def self.create(wizard_id, user = nil)
|
def self.create(wizard_id, user = nil)
|
||||||
if wizard = self.find(wizard_id)
|
if wizard = self.find(wizard_id)
|
||||||
CustomWizard::Wizard.new(wizard.to_h, user)
|
self.new(wizard.to_h, user)
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -355,7 +355,7 @@ class CustomWizard::Wizard
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.set_wizard_redirect(wizard_id, user)
|
def self.set_wizard_redirect(wizard_id, user)
|
||||||
wizard = CustomWizard::Wizard.create(wizard_id, user)
|
wizard = self.create(wizard_id, user)
|
||||||
|
|
||||||
if wizard.permitted?
|
if wizard.permitted?
|
||||||
user.custom_fields['redirect_to_wizard'] = wizard_id
|
user.custom_fields['redirect_to_wizard'] = wizard_id
|
||||||
|
|
|
@ -118,8 +118,8 @@ after_initialize do
|
||||||
end
|
end
|
||||||
|
|
||||||
on(:user_approved) do |user|
|
on(:user_approved) do |user|
|
||||||
if wizard_id = CustomWizard::Wizard.after_signup(user)
|
if wizard = CustomWizard::Wizard.after_signup(user)
|
||||||
CustomWizard::Wizard.set_wizard_redirect(wizard_id, user)
|
CustomWizard::Wizard.set_wizard_redirect(wizard.id, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren