public ConfModule() { this.RequiresAuthentication(); Post["/cfg/addvalue"] = x => { var tag = (string)Request.Form.Tag; var key = (string)Request.Form.Key; var value = (string)Request.Form.Value; if (key.Length > 0) { ConfigManagement.AddValuesBundle(tag, key, value); } else { ConfigManagement.AddValuesBundle(tag, value); } return(Response.AsRedirect("/")); }; Post["/cfg/delvalue"] = x => { var tag = (string)Request.Form.Tag; var key = (string)Request.Form.Key; var value = (string)Request.Form.Value; ConfigManagement.DeleteValuesBundle(tag, key, value); return(Response.AsRedirect("/")); }; Get["/cfg/tags"] = x => { var data = ConfigManagement.GetTagsBundleValue(); var map = SelectizerMapModel.MapRawTagOfValueBundle(data); return(Response.AsJson(map)); }; Post["/cfg/addcommand"] = x => { var command = (string)Request.Form.Command; if (command.Length > 0) { ConfigManagement.AddCommandsBundle(command); } return(Response.AsRedirect("/")); }; Post["/cfg/delcommand"] = x => { var guid = (string)Request.Form.Guid; ConfigManagement.DeleteCommandsBundle(guid); return(Response.AsRedirect("/")); }; Post["/cfg/enablecommand"] = x => { var guid = (string)Request.Form.Guid; ConfigManagement.EnableCommand(guid); return(Response.AsJson(true)); }; Post["/cfg/disablecommand"] = x => { var guid = (string)Request.Form.Guid; ConfigManagement.DisableCommand(guid); return(Response.AsJson(true)); }; Post["/cfg/launchcommand"] = x => { var guid = (string)Request.Form.Guid; ConfigManagement.LaunchCommand(guid); return(Response.AsRedirect("/")); }; Post["/cfg/reindex"] = x => { var guid = (string)Request.Form.Guid; var index = (string)Request.Form.Index; var guids = guid.Split(','); var indexes = index.Split(','); for (var i = 0; i < guids.Length; i++) { ConfigManagement.AssignIndexToCommandsBundle(guids[i], indexes[i]); } return(Response.AsRedirect("/")); }; Get["/cfg/getenabled"] = x => { var data = ConfigManagement.GetCommandsBundle().Where(_ => _.IsEnabled); return(Response.AsJson(data)); }; Get["/cfg/layouts"] = x => { var data = ConfigManagement.GetCommandsBundleLayout(); var map = SelectizerMapModel.MapRawCommandBundleLayout(data); return(Response.AsJson(map)); }; Post["/cfg/export"] = x => { ConfigManagement.Export.ExportConfigurationToFile(); return(Response.AsJson(true)); }; }
public UsersModule() { this.RequiresAuthentication(); Get["/users/json"] = x => Response.AsJson(SelectizerMapModel.MapRawUserEntity(UserEntity.Repository.GetAll())); Post["/users/refresh/users"] = x => { SystemUser.ImportUsersToDatabase(); return(Response.AsJson(true)); }; Post["/users/refresh/group"] = x => { SystemGroup.ImportGroupsToDatabase(); return(Response.AsJson(true)); }; Post["/users/create"] = x => { string name = Request.Form.Name; SystemUser.CreateUser(name); return(Response.AsRedirect("/")); }; Post["/users/create/group"] = x => { string name = Request.Form.Name; SystemGroup.CreateGroup(name); return(Response.AsRedirect("/")); }; Post["/users/sysmap/create"] = x => { string user = Request.Form.UserAlias; string pwd = Request.Form.UserPassword; SystemUser.Map.MapUser(user, pwd); return(Response.AsRedirect("/")); }; Get["/users/identity"] = x => { dynamic vmod = new ExpandoObject(); vmod.Users = UserEntity.Repository.GetAll(); return(View["_page-users", vmod]); }; Post["/users/identity"] = x => { var guid = UserEntity.Repository.GenerateGuid(); string userIdentity = Request.Form.UserEntity; string userPassword = Request.Form.UserPassword; var alias = UserEntity.Repository.GenerateUserAlias(userIdentity); var claims = new List <UserEntity.UserEntityModel.Claim> { new UserEntity.UserEntityModel.Claim { ClaimGuid = guid, Mode = UserEntity.ClaimMode.Antd, Type = UserEntity.ClaimType.UserIdentity, Key = "antd-master-id", Value = guid }, new UserEntity.UserEntityModel.Claim { ClaimGuid = guid, Mode = UserEntity.ClaimMode.Antd, Type = UserEntity.ClaimType.UserIdentity, Key = "antd-master-identity", Value = userIdentity }, new UserEntity.UserEntityModel.Claim { ClaimGuid = guid, Mode = UserEntity.ClaimMode.Antd, Type = UserEntity.ClaimType.UserIdentity, Key = "antd-master-alias", Value = alias }, new UserEntity.UserEntityModel.Claim { ClaimGuid = guid, Mode = UserEntity.ClaimMode.Antd, Type = UserEntity.ClaimType.UserPassword, Key = "antd-master-password", Value = Cryptography.Hash256ToString(userPassword) } }; UserEntity.Repository.Create(guid, userIdentity, alias, claims); return(Response.AsRedirect("/")); }; Post["/users/identity/addclaim"] = x => { string userGuid = Request.Form.Userguid; string type = Request.Form.Type.Value; string mode = Request.Form.Mode.Value; string key = Request.Form.Key; string val = Request.Form.Value; UserEntity.Repository.AddClaim(userGuid, UserEntity.ConvertClaimType(type), UserEntity.ConvertClaimMode(mode), key, val); return(Response.AsRedirect("/")); }; Post["/users/identity/delclaim"] = x => { string userGuid = Request.Form.Userguid; string guid = Request.Form.Guid; UserEntity.Repository.RemoveClaim(userGuid, guid); return(Response.AsRedirect("/")); }; }