From 79086dcf4576e5c1c8afd5fec974c0b749172869 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Mon, 16 May 2016 00:16:19 -0400 Subject: [PATCH] Added in an audit table. Since we are now allowing multiple users to change and modify things we need to audit this. --- PlexRequests.Helpers/UserClaims.cs | 6 +++--- PlexRequests.Store/Models/Audit.cs | 16 ++++++++++++++++ PlexRequests.Store/PlexRequests.Store.csproj | 1 + PlexRequests.Store/SqlTables.sql | 12 ++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 PlexRequests.Store/Models/Audit.cs diff --git a/PlexRequests.Helpers/UserClaims.cs b/PlexRequests.Helpers/UserClaims.cs index 15c2af110..e53aabeab 100644 --- a/PlexRequests.Helpers/UserClaims.cs +++ b/PlexRequests.Helpers/UserClaims.cs @@ -4,9 +4,9 @@ namespace PlexRequests.Helpers { public class UserClaims { - public const string Admin = "Admin"; - public const string PowerUser = "PowerUser"; - public const string User = "User"; + public const string Admin = "Admin"; // Can do everything including creating new users and editing settings + public const string PowerUser = "PowerUser"; // Can only manage the requests, approve etc. + public const string User = "User"; // Can only request } } diff --git a/PlexRequests.Store/Models/Audit.cs b/PlexRequests.Store/Models/Audit.cs new file mode 100644 index 000000000..b0edc4aad --- /dev/null +++ b/PlexRequests.Store/Models/Audit.cs @@ -0,0 +1,16 @@ +using System; +using Dapper.Contrib.Extensions; + +namespace PlexRequests.Store +{ + [Table("Audit")] + public class Audit : Entity + { + public string Username{get;set;} + public DateTime Date {get;set;} + public string ChangeType {get;set;} + public string OldValue {get;set;} + public string NewValue{get;set;} + } +} + diff --git a/PlexRequests.Store/PlexRequests.Store.csproj b/PlexRequests.Store/PlexRequests.Store.csproj index ad8dd61b7..8d52b35d7 100644 --- a/PlexRequests.Store/PlexRequests.Store.csproj +++ b/PlexRequests.Store/PlexRequests.Store.csproj @@ -81,6 +81,7 @@ Sql.resx + diff --git a/PlexRequests.Store/SqlTables.sql b/PlexRequests.Store/SqlTables.sql index 7a1cbed63..842bffa29 100644 --- a/PlexRequests.Store/SqlTables.sql +++ b/PlexRequests.Store/SqlTables.sql @@ -42,6 +42,18 @@ CREATE TABLE IF NOT EXISTS Logs ); CREATE UNIQUE INDEX IF NOT EXISTS Logs_Id ON Logs (Id); +CREATE TABLE IF NOT EXISTS Audit +( + Id INTEGER PRIMARY KEY AUTOINCREMENT, + Date varchar(100) NOT NULL, + Username varchar(100) NOT NULL, + ChangeType varchar(100) NOT NULL, + OldValue varchar(100), + NewValue varchar(100), +); +CREATE UNIQUE INDEX IF NOT EXISTS Audit_Id ON Audit (Id); + + CREATE TABLE IF NOT EXISTS DBInfo ( SchemaVersion INTEGER