reset_password.rake

Jan Niggemann (redmine.org team member), 2013-01-08 22:34

Download (935 Bytes)

 
1
desc "Create a new account resetadmin and set its password to admin"
2

    
3
require 'active_record'
4

    
5
namespace :redmine do
6
        task :resetpw => :environment do
7
                class ResetUser < ActiveRecord::Base
8
                        self.table_name = 'users'
9
                        attr_accessible :login, :hashed_password, :admin, :type, :firstname, :lastname, :mail, :mail_notification, :language, :status
10
                end
11
                user = ResetUser.new(:login =>'resetadmin',
12
                        :hashed_password => 'd033e22ae348aeb5660fc2140aec35850c4da997',
13
                        :admin => true,
14
                        :type => 'User',
15
                        :firstname => 'Redmine Reset',
16
                        :lastname => 'Admin',
17
                        :mail => 'admin@example.net',
18
                        :mail_notification => true,
19
                        :language => 'en',
20
                        :status => 1)
21
                user.save
22
                User.salt_unsalted_passwords!
23
                puts "Created a new account, you can now login as user 'resetadmin' with password 'admin' and change the password of your admin account."
24
                puts "Please make sure you delete the account 'resetadmin' afterwards!"
25
        end
26
end