2024-06-17 09:45:51 +00:00
|
|
|
# Load the Discourse environment
|
2024-08-29 10:09:26 +00:00
|
|
|
require File.expand_path("../../../../config/environment", __FILE__)
|
2024-06-17 09:45:51 +00:00
|
|
|
|
|
|
|
# require_relative '/var/www/discourse/config/environment'
|
|
|
|
|
|
|
|
def set_user_password(username, new_password)
|
|
|
|
user = User.find_by(username: username)
|
|
|
|
if user
|
|
|
|
# Use the `password=` method to properly hash the password
|
|
|
|
user.password = new_password
|
|
|
|
user.save!
|
|
|
|
puts "Password updated for user: #{username}"
|
|
|
|
else
|
|
|
|
puts "User not found: #{username}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Replace 'username' and 'new_password' with actual values
|
|
|
|
username = 'davidpaulyoung'
|
|
|
|
new_password = 'T3s7P4ssw0rd.'
|
|
|
|
|
|
|
|
set_user_password(username, new_password)
|