password reset fix

This commit is contained in:
2026-08-21 21:28:10 +02:00
parent 92b4ae22b7
commit f2d0b72afd
3 changed files with 29 additions and 5 deletions
+28
View File
@@ -0,0 +1,28 @@
namespace :admin_user do
desc "Set an admin user password: rake admin_user:password EMAIL=... PASSWORD=..."
task password: :environment do
email = ENV["EMAIL"].to_s.strip
password = ENV["PASSWORD"].to_s
if email.empty? || password.empty?
abort "Használat: rake admin_user:password EMAIL=admin@teletype.hu PASSWORD=újjelszó"
end
user = AdminUser.find_by(email: email)
abort "Nincs ilyen admin user: #{email}" if user.nil?
user.password = password
user.password_confirmation = password
if user.save
puts "Jelszó frissítve: #{user.email}"
else
abort "Sikertelen: #{user.errors.full_messages.join(', ')}"
end
end
desc "List admin users"
task list: :environment do
AdminUser.order(:email).each { |u| puts "#{u.id}\t#{u.email}" }
end
end