Add customizable user roles (#18641)
* Add customizable user roles * Various fixes and improvements * Add migration for old settings and fix tootctl role management
This commit is contained in:
parent
1b4054256f
commit
44b2ee3485
187 changed files with 1945 additions and 1032 deletions
1
db/seeds/01_web_app.rb
Normal file
1
db/seeds/01_web_app.rb
Normal file
|
@ -0,0 +1 @@
|
|||
Doorkeeper::Application.create_with(name: 'Web', redirect_uri: Doorkeeper.configuration.native_redirect_uri, scopes: 'read write follow push').find_or_create_by(superapp: true)
|
1
db/seeds/02_instance_actor.rb
Normal file
1
db/seeds/02_instance_actor.rb
Normal file
|
@ -0,0 +1 @@
|
|||
Account.create_with(actor_type: 'Application', locked: true, username: ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain).find_or_create_by(id: -99)
|
9
db/seeds/03_roles.rb
Normal file
9
db/seeds/03_roles.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Pre-create base role
|
||||
UserRole.everyone
|
||||
|
||||
# Create default roles defined in config file
|
||||
default_roles = YAML.load_file(Rails.root.join('config', 'roles.yml'))
|
||||
|
||||
default_roles.each do |_, config|
|
||||
UserRole.create_with(position: config['position'], permissions_as_keys: config['permissions'], highlighted: true).find_or_create_by(name: config['name'])
|
||||
end
|
8
db/seeds/04_admin.rb
Normal file
8
db/seeds/04_admin.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
if Rails.env.development?
|
||||
domain = ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain
|
||||
|
||||
admin = Account.where(username: 'admin').first_or_initialize(username: 'admin')
|
||||
admin.save(validate: false)
|
||||
|
||||
User.where(email: "admin@#{domain}").first_or_initialize(email: "admin@#{domain}", password: 'mastodonadmin', password_confirmation: 'mastodonadmin', confirmed_at: Time.now.utc, role: UserRole.find_by(name: 'Owner'), account: admin, agreement: true, approved: true).save!
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue