mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Implement role authorization
This commit is contained in:
parent
6755328c4c
commit
e2fb434dc7
122 changed files with 1386 additions and 751 deletions
|
|
@ -1,6 +1,7 @@
|
|||
module Admin
|
||||
class UsersController < ApplicationController
|
||||
before_filter :verify_admin
|
||||
load_and_authorize_resource
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
|
|
@ -10,34 +11,37 @@ module Admin
|
|||
end
|
||||
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
|
||||
# Variable @show_attributes holds the attributes that are visible for the 'show' action
|
||||
# If you want to change the attributes that are shown in the 'show' action of users
|
||||
# add/remove the attributes in the following string array
|
||||
@show_attributes = %w(name email affiliation biography registered attended created_at
|
||||
@show_attributes = %w(name email affiliation biography registered attended roles created_at
|
||||
updated_at sign_in_count current_sign_in_at last_sign_in_at
|
||||
current_sign_in_ip last_sign_in_ip)
|
||||
end
|
||||
|
||||
def update
|
||||
user = User.find(params[:id])
|
||||
user.update_attributes!(params[:user])
|
||||
redirect_to admin_users_path, notice: "Updated #{user.email}"
|
||||
params[:user].delete :roles_attributes if params[:user]
|
||||
@user.update_attributes!(params[:user])
|
||||
redirect_to admin_users_path, notice: "Updated #{@user.email}"
|
||||
end
|
||||
|
||||
def add_role
|
||||
role = params[:user][:roles_attributes][:"0"]
|
||||
@user.add_role role['name'].parameterize.underscore.to_sym, Conference.find(role['resource_id'])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def delete
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@user = User.find(params[:id])
|
||||
@user.destroy
|
||||
redirect_to admin_users_path, notice: 'User got deleted'
|
||||
redirect_to admin_users_path, notice: "User #{@user.name} (#{@user.email})got deleted"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue