From 7d113995741158441aae67a0d5aeb3b076ca3c44 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 May 2019 19:03:50 +0000 Subject: [PATCH] --- devdocs/specs/core-roles.txt | 2 -- devdocs/todo.txt | 27 +++++++++++++++++---------- server/AyaNova/biz/LocaleBiz.cs | 5 ++--- server/AyaNova/biz/UserBiz.cs | 20 ++++---------------- server/AyaNova/models/Locale.cs | 3 +-- server/AyaNova/models/User.cs | 3 +-- server/AyaNova/util/AySchema.cs | 4 ++-- 7 files changed, 27 insertions(+), 37 deletions(-) diff --git a/devdocs/specs/core-roles.txt b/devdocs/specs/core-roles.txt index 2933bb06..df66d2d4 100644 --- a/devdocs/specs/core-roles.txt +++ b/devdocs/specs/core-roles.txt @@ -138,5 +138,3 @@ nothing to do with business stuff or actual business data - EditOwn is really not about editown it's about supporting a user who is not supposed to see any data other than the bare minimum in order to fill out workorders - Make it a business rule(s) instead in the areas of workorders and anything specific - Get rid of edit own rights code entirely - - this might mean can clean up ownerID stuff in objects? - diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 0108efc5..c61092d8 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -6,16 +6,23 @@ Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTQ3NTgwMzg2IiwiZXhwIjoi ## IMMEDIATE ITEMS -Do I need ownerId for anything if it's not being used anymore for rules?? - - Get rid of it in all rights stuff first, then widget then the rest and rename for the below specific things to UserId instead - - DataFilter uses it for a different purpose in that there are public and private filters - - After removing everywhere else maybe if this is the only holdout rename the field to userID or something? - - Semantically makes more sense - - Also helps so we can have no remnants of ownerId anywhere to make it easier to see what's been fixed / changed. - - EventLog uses it to log people's changes so an eventlog entry might be owned by Jim but it refers to an action Jim made on another object such as edit it maybe - - Could be renamed to UserId as well - - Event object uses it see eventlog above - - FormCustom uses it much like DataFilter does, could also be renamed to UserId and semantically be better +Remove OwnerId + - DONE Get rid of it in all rights stuff first + - Remove OwnerId for objects that don't require it anymore + - DONE Widget + - DONE Locale + - DONE User + - UserOptions remove but also has a bit below + - ValidateJsonPatch + - FileAttachment + + - Rename OwnerId to UserId for those objects that require it still + - DataFilter + - EventLog + - Event object uses it see eventlog above + - FormCustom uses it much like DataFilter does, could also be renamed to UserId and semantically be better + - UserOptions (rename to userID) + - OpsJob (might be removable?) OwnerID is put on httpcontext in startup.cs, will it still be necessary? Clean up owner ID and rules now that it's deprecated diff --git a/server/AyaNova/biz/LocaleBiz.cs b/server/AyaNova/biz/LocaleBiz.cs index 857a1912..612f1907 100644 --- a/server/AyaNova/biz/LocaleBiz.cs +++ b/server/AyaNova/biz/LocaleBiz.cs @@ -65,7 +65,7 @@ namespace AyaNova.Biz //replicate the source to a new dest and save Locale NewLocale = new Locale(); NewLocale.Name = inObj.Name; - NewLocale.OwnerId = UserId; + NewLocale.Stock = false; NewLocale.CjkIndex = false; foreach (LocaleItem i in SourceLocale.LocaleItems) @@ -571,8 +571,7 @@ namespace AyaNova.Biz //have file name, have all localized text Locale l = new Locale(); - l.Name = SourceLocaleName; - l.OwnerId = 1; + l.Name = SourceLocaleName; l.Stock = false; foreach (KeyValuePair K in NewLocaleDict) diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 31563879..d461b75b 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -58,7 +58,7 @@ namespace AyaNova.Biz inObj.Salt = Hasher.GenerateSalt(); inObj.Password = Hasher.hash(inObj.Salt, inObj.Password); - inObj.OwnerId = UserId; + inObj.Tags = TagUtil.NormalizeTags(inObj.Tags); //Seeder sets user options in advance so no need to create them here in that case if (inObj.UserOptions == null) @@ -99,7 +99,7 @@ namespace AyaNova.Biz //This is a new user so it will have been posted with a password in plaintext which needs to be salted and hashed inObj.Salt = Hasher.GenerateSalt(); inObj.Password = Hasher.hash(inObj.Salt, inObj.Password); - inObj.OwnerId = UserId; + inObj.Tags = TagUtil.NormalizeTags(inObj.Tags); //Seeder sets user options in advance so no need to create them here in that case if (inObj.UserOptions == null) @@ -256,9 +256,7 @@ namespace AyaNova.Biz //put internal bool Put(User dbObj, User inObj) { - //preserve the owner ID if none was specified - if (inObj.OwnerId == 0) - inObj.OwnerId = dbObj.OwnerId; + //Get a snapshot of the original db value object before changes User SnapshotOfOriginalDBObj = new User(); @@ -412,13 +410,6 @@ namespace AyaNova.Biz //also check user count in general to see if it's exceeded //And maybe check it in login as well as a good central spot or wherever makes sense - //OwnerId required - if (!isNew) - { - if (proposedObj.OwnerId == 0) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId"); - } - //Name required if (string.IsNullOrWhiteSpace(proposedObj.Name)) AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); @@ -577,8 +568,7 @@ namespace AyaNova.Biz return new { Id = o.Id, - ConcurrencyToken = o.ConcurrencyToken, - OwnerId = o.OwnerId, + ConcurrencyToken = o.ConcurrencyToken, Active = o.Active, Name = o.Name, Roles = o.Roles, @@ -723,8 +713,6 @@ namespace AyaNova.Biz //Copy values User i = new User(); - //default owner id is manager account in RAVEN - i.OwnerId = 1; i.Name = j["FirstName"].Value() + " " + j["LastName"].Value(); var Temp = j["UserType"].Value(); diff --git a/server/AyaNova/models/Locale.cs b/server/AyaNova/models/Locale.cs index 2f57dc54..f000c310 100644 --- a/server/AyaNova/models/Locale.cs +++ b/server/AyaNova/models/Locale.cs @@ -13,8 +13,7 @@ namespace AyaNova.Models { public long Id { get; set; } public uint ConcurrencyToken { get; set; } - [Required] - public long OwnerId { get; set; } + [Required] public string Name { get; set; } diff --git a/server/AyaNova/models/User.cs b/server/AyaNova/models/User.cs index c78ff286..98a39386 100644 --- a/server/AyaNova/models/User.cs +++ b/server/AyaNova/models/User.cs @@ -10,8 +10,7 @@ namespace AyaNova.Models { public long Id { get; set; } public uint ConcurrencyToken { get; set; } - [Required] - public long OwnerId { get; set; } + [Required] public bool Active { get; set; } [Required, MaxLength(255)] diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 1846ad37..9a9be905 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -148,7 +148,7 @@ namespace AyaNova.Util exec("CREATE TABLE asearchkey (id BIGSERIAL PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null, inname bool not null)"); //create locale text tables - exec("CREATE TABLE alocale (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, stock bool, cjkindex bool default false)"); + exec("CREATE TABLE alocale (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)"); //LOOKAT: I don't think this is doing anything: //exec("CREATE UNIQUE INDEX alocale_name_idx ON alocale (name)"); @@ -164,7 +164,7 @@ namespace AyaNova.Util //Add user table - exec("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, active bool not null, name varchar(255) not null, " + + exec("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null, " + "login text not null, password text not null, salt text not null, roles integer not null, localeid bigint not null REFERENCES alocale (id), " + "dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, clientid bigint, " + "headofficeid bigint, subvendorid bigint, customfields text, tags varchar(255) ARRAY)");