Skip to content

Instantly share code, notes, and snippets.

@togakangaroo
Last active August 29, 2015 14:04
Show Gist options
  • Save togakangaroo/5ea2dd1a86729af8eea0 to your computer and use it in GitHub Desktop.
Save togakangaroo/5ea2dd1a86729af8eea0 to your computer and use it in GitHub Desktop.
app.SimpleAuthorization("/Admin/SimpleTableEditor/France/UserPermissions", (owinEnvironment) =>
Ogre.RoleConfiguration.GetRolesForUser(owinEnvironment["username"].ToString()).Contains("Editor"))
//^ Not exactly sure how to do Authorization. Should probably go in its own Nuget package?
// My idea is basically just for any request to that route run the lambda, and 401 if it returns false.
app.UseSimpleTableEditor(new SimpleTableEditorOptions {
Url = "/Admin/SimpleTableEditor/France/UserPermissions",
Label = "France - User Permissions",
ConnectionString: x => x.ConnectionString( OgreDeployment.ConnectionString("frenchDatamart") ), //Nested closure rather than just interface to make it easier to find
//^ or x => x.ConnectionStringName("frenchDatamart") which will pluck the value out of ConfigurationManager
JoinTable = new SimpleTableEditor.JoinTable {
Label = "Users in Categories"
TableName = "dbo.usersInCategories",
LeftChild = new SimpleTableEditor.JoinTableChild {
Label = "Users",
TableName = "dbo.users",
KeyColumn = "userId",
ParentKeyColumn = "userId",
},
RightChild = new SimpleTableEditor.JoinTableChild {
Label = "Categories",
TableName = "dbo.categories",
KeyColumn = "categoryId",
ParentKeyColumn = "categoryId",
},
},
IncludeStylesheet = "/Stylesheets/SimpleTableEditor.css",
//^ Optional, but if present request this stylesheet from the generated page
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment