Authorisation management using CanCanCan added

This commit is contained in:
Christoph Haas 2021-02-28 21:36:46 +01:00
parent 51be4a4777
commit 7a3b65fe50
24 changed files with 211 additions and 295 deletions

View file

@ -0,0 +1,10 @@
class DropDeprecatedScreenshotsFields < ActiveRecord::Migration[6.1]
def change
remove_column :screenshots, :markedfordelete
remove_column :screenshots, :delete_reason
remove_column :screenshots, :image_file_name
remove_column :screenshots, :image_content_type
remove_column :screenshots, :image_file_size
remove_column :screenshots, :image_updated_at
end
end

View file

@ -0,0 +1,14 @@
# Rename the :admin field to :admin_role and change integer to boolean
class AddRolesToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :admin_role, :boolean, default: false
User.find_each do |user|
user.admin_role=true if user.admin>0
user.save!
end
remove_column :users, :admin
add_column :users, :moderator_role, :boolean, default: false
end
end

View file

@ -0,0 +1,8 @@
# Create a pseudo flag for accounts that get automatically created.
# If an anonymous visitor uploads a screenshot he will get a
# pseudo account to assign the screenshots to.
class AddPseudoColumnToUser < ActiveRecord::Migration[6.1]
def change
add_column :users, :pseudo, :boolean, default: false
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_02_22_102719) do
ActiveRecord::Schema.define(version: 2021_02_28_191717) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -88,14 +88,8 @@ ActiveRecord::Schema.define(version: 2021_02_22_102719) do
t.datetime "created_at"
t.string "uploaderhash", limit: 72
t.boolean "approved", default: false, null: false
t.boolean "markedfordelete"
t.string "delete_reason", limit: 100
t.text "description"
t.datetime "updated_at"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "image_fingerprint"
t.integer "user_id", default: 0
t.text "simage_data"
@ -120,7 +114,9 @@ ActiveRecord::Schema.define(version: 2021_02_22_102719) do
t.datetime "locked_at"
t.string "provider"
t.string "uid"
t.integer "admin", default: 0
t.boolean "admin_role", default: false
t.boolean "moderator_role", default: false
t.boolean "pseudo", default: false
t.index ["email", "provider"], name: "index_users_on_email_and_provider", unique: true
end