mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 04:05:35 +08:00
Refactor admin create task
This commit is contained in:
parent
0f25bbeaf7
commit
48940b9bbe
@ -10,8 +10,8 @@ task "admin:create" => :environment do
|
|||||||
if existing_user
|
if existing_user
|
||||||
# user already exists, ask for password reset
|
# user already exists, ask for password reset
|
||||||
admin = existing_user
|
admin = existing_user
|
||||||
reset_password = ask("User with this email already exists! Do you want to reset the password for this email? (y/n) ")
|
reset_password = ask("User with this email already exists! Do you want to reset the password for this email? (Y/n) ")
|
||||||
if (reset_password.downcase == 'y')
|
if (reset_password == "" || reset_password.downcase == 'y')
|
||||||
begin
|
begin
|
||||||
password = ask("Password: ") {|q| q.echo = false}
|
password = ask("Password: ") {|q| q.echo = false}
|
||||||
password_confirmation = ask("Repeat password: ") {|q| q.echo = false}
|
password_confirmation = ask("Repeat password: ") {|q| q.echo = false}
|
||||||
@ -46,8 +46,8 @@ task "admin:create" => :environment do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# grant admin privileges
|
# grant admin privileges
|
||||||
grant_admin = ask("Do you want to grant Admin privileges to this account? (y/n) ")
|
grant_admin = ask("Do you want to grant Admin privileges to this account? (Y/n) ")
|
||||||
if (grant_admin.downcase == 'y')
|
if (grant_admin == "" || grant_admin.downcase == 'y')
|
||||||
admin.grant_admin!
|
admin.grant_admin!
|
||||||
admin.change_trust_level!(TrustLevel.levels.max_by{|k, v| v}[0])
|
admin.change_trust_level!(TrustLevel.levels.max_by{|k, v| v}[0])
|
||||||
admin.email_tokens.update_all confirmed: true
|
admin.email_tokens.update_all confirmed: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user