Abilities für Rollenvergabe

This commit is contained in:
Andreas Stephanides
2013-08-18 17:56:54 +02:00
parent 6f6486c7ae
commit b748382df4
2 changed files with 9 additions and 0 deletions

View File

@@ -4,7 +4,13 @@ class UsersController < ApplicationController
end end
def add_role def add_role
@user= User.find(params[:id]) @user= User.find(params[:id])
if (params[:role]=="fetuser" && can?(:addfetuser,User))
@user.add_role(params[:role]) @user.add_role(params[:role])
end
if (params[:role]=="fetadmin" && can?(:addfetadmin,User))
@user.add_role(params[:role])
end
end end
def do_confirm def do_confirm
@user= User.find(params[:id]) @user= User.find(params[:id])

View File

@@ -28,6 +28,8 @@ class Ability
# For Debug allow everything # For Debug allow everything
# Remove this line in production environment and for testing user management # Remove this line in production environment and for testing user management
can :manage, :all can :manage, :all
can :addfetuser, User
can :addfetadmin, User
can [:show, :index], Studium can [:show, :index], Studium
can [:show, :index], Modulgruppe can [:show, :index], Modulgruppe
can [:show, :index], Modul can [:show, :index], Modul
@@ -39,6 +41,7 @@ class Ability
# Rechteverwaltung Kalender # Rechteverwaltung Kalender
can [:show, :index], Calendar, :public => true can [:show, :index], Calendar, :public => true
can [:showics], Calendar
can [:show], Calentry can [:show], Calentry
if( user.has_role?("fetuser") || user.has_role?("fetadmin")) if( user.has_role?("fetuser") || user.has_role?("fetadmin"))