mirror of
https://github.com/discourse/discourse.git
synced 2025-04-28 04:44:34 +08:00
DEV: allow creating users with random passwords via rake
Use: `RANDOM_PASSWORD=1 bin/rake admin:create` Handy in conjunction with dev mode /session/username/become.
This commit is contained in:
parent
f67cc2a540
commit
abbbcb2622
@ -56,8 +56,12 @@ task "admin:create" => :environment do
|
|||||||
admin.email = email
|
admin.email = email
|
||||||
admin.username = UserNameSuggester.suggest(admin.email)
|
admin.username = UserNameSuggester.suggest(admin.email)
|
||||||
begin
|
begin
|
||||||
password = ask("Password: ") { |q| q.echo = false }
|
if ENV["RANDOM_PASSWORD"] == "1"
|
||||||
password_confirmation = ask("Repeat password: ") { |q| q.echo = false }
|
password = password_confirmation = SecureRandom.hex
|
||||||
|
else
|
||||||
|
password = ask("Password: ") { |q| q.echo = false }
|
||||||
|
password_confirmation = ask("Repeat password: ") { |q| q.echo = false }
|
||||||
|
end
|
||||||
end while password != password_confirmation
|
end while password != password_confirmation
|
||||||
admin.password = password
|
admin.password = password
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user