ref: refs/heads/basesystem
commit caa6a1a1ebca6f47cb7272e4965cbf3392fe3993
Author: Josef Reidinger
Date: Thu Sep 3 09:22:51 2009 +0200
add comments to permission check and also add shortcut for yapi permissions
---
webservice/lib/yast_roles.rb | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/webservice/lib/yast_roles.rb b/webservice/lib/yast_roles.rb
index 49992da..bfc7b76 100644
--- a/webservice/lib/yast_roles.rb
+++ b/webservice/lib/yast_roles.rb
@@ -17,6 +17,22 @@ module YastRoles
public
+ # Shortcut for yapi permission so it is enought to write
+ # yapi_perm_check "time.read"
+ # instead
+ # permission_check "org.opensuse.yast.modules.yapi.time.read"
+ # for more details see permission_check
+ def yapi_perm_check(action)
+ permission_check "org.opensuse.yast.modules.yapi.#{action}"
+ end
+
+ # Check if permission user can do selected action. Check also roles in which user act.
+ # <b>action</b>:: name of target action
+ # <b>throws</b> :: throwed exceptions:
+ # - _NotLoggedException_ if no user is logged
+ # - _NoPermissionException_ if permission is not granted
+ # - _PolicyKitException_ for error during running policy kit
+ #
def permission_check(action)
return true if ENV["RAILS_ENV"] == "test"
raise NotLoggedException if self.current_account==nil || self.current_account.login.size == 0
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org