[completed: 566] Host.CheckActionFor* methods now accept null user and treat it as anonymous.

This commit is contained in:
Dario Solera 2011-04-06 18:35:10 +02:00
parent 1643ac8b35
commit 4249a761d7
2 changed files with 14 additions and 11 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.4.560")] [assembly: AssemblyVersion("3.0.4.561")]
[assembly: AssemblyFileVersion("3.0.4.560")] [assembly: AssemblyFileVersion("3.0.4.561")]

View file

@ -215,9 +215,10 @@ namespace ScrewTurn.Wiki {
public bool CheckActionForGlobals(string action, UserInfo user) { public bool CheckActionForGlobals(string action, UserInfo user) {
if(action == null) throw new ArgumentNullException("action"); if(action == null) throw new ArgumentNullException("action");
if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action"); if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action");
if(user == null) throw new ArgumentNullException("user");
return AuthChecker.CheckActionForGlobals(action, user.Username, user.Groups); var temp = user != null ? user : Users.GetAnonymousAccount();
return AuthChecker.CheckActionForGlobals(action, temp.Username, temp.Groups);
} }
/// <summary> /// <summary>
@ -232,9 +233,10 @@ namespace ScrewTurn.Wiki {
public bool CheckActionForNamespace(NamespaceInfo nspace, string action, UserInfo user) { public bool CheckActionForNamespace(NamespaceInfo nspace, string action, UserInfo user) {
if(action == null) throw new ArgumentNullException("action"); if(action == null) throw new ArgumentNullException("action");
if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action"); if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action");
if(user == null) throw new ArgumentNullException("user");
return AuthChecker.CheckActionForNamespace(nspace, action, user.Username, user.Groups); var temp = user != null ? user : Users.GetAnonymousAccount();
return AuthChecker.CheckActionForNamespace(nspace, action, temp.Username, temp.Groups);
} }
/// <summary> /// <summary>
@ -250,9 +252,10 @@ namespace ScrewTurn.Wiki {
if(page == null) throw new ArgumentNullException("page"); if(page == null) throw new ArgumentNullException("page");
if(action == null) throw new ArgumentNullException("action"); if(action == null) throw new ArgumentNullException("action");
if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action"); if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action");
if(user == null) throw new ArgumentNullException("user");
return AuthChecker.CheckActionForPage(page, action, user.Username, user.Groups); var temp = user != null ? user : Users.GetAnonymousAccount();
return AuthChecker.CheckActionForPage(page, action, temp.Username, temp.Groups);
} }
/// <summary> /// <summary>
@ -268,10 +271,10 @@ namespace ScrewTurn.Wiki {
if(directory == null) throw new ArgumentNullException("directory"); if(directory == null) throw new ArgumentNullException("directory");
if(action == null) throw new ArgumentNullException("action"); if(action == null) throw new ArgumentNullException("action");
if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action"); if(action.Length == 0) throw new ArgumentException("Action cannot be empty", "action");
if(user == null) throw new ArgumentNullException("user");
return AuthChecker.CheckActionForDirectory(directory.Provider, directory.FullPath, action, var temp = user != null ? user : Users.GetAnonymousAccount();
user.Username, user.Groups);
return AuthChecker.CheckActionForDirectory(directory.Provider, directory.FullPath, action, temp.Username, temp.Groups);
} }
/// <summary> /// <summary>