/// <summary> /// Check is user has permission to invoke action on organization /// </summary> /// <param name="user"></param> /// <param name="action"></param> /// <param name="organization"></param> /// <returns></returns> public static bool Check(SystemUser user, ActionType action, Organization organization) { if (user == null) { //TODO: an anonymouse user can have access to some functions return false; } OrganizationPermission permission = Db.SQL<OrganizationPermission>("SELECT o FROM Warehouse.OrganizationPermission o WHERE o.User=? AND o.Organization=?", user, organization).First; if (permission != null) { // TODO: Add what kind of check, CanRead, CanUpdate or CanDelete return true; } return false; }
private static Depot CreateDepot(string name, Organization org) { SystemUser user = SystemUser.GetCurrentSystemUser(); Depot depot = new Depot { Name = name, UrlName = name.GenerateSlug(), ID = string.Format("{0:X8}", (org.Name.GenerateSlug() + name.GenerateSlug()).GetHashCode()) }; depot.Organization = org; new DepotPermission() { User = user, Depot = depot }; return depot; }
private static Organization CreateOrganization(string name) { SystemUser user = SystemUser.GetCurrentSystemUser(); Organization org = new Organization() { Name = name, UrlName = name.GenerateSlug(), ID = string.Format("{0:X8}", (name).GetHashCode()) }; new OrganizationPermission() { User = user, Organization = org }; return org; }