This commit is contained in:
@@ -368,7 +368,7 @@ namespace AyaNova
|
||||
var ct = context.RequestServices.GetService<AyContext>();
|
||||
|
||||
//get the user record
|
||||
var u = await ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, translationId = m.TranslationId }).FirstAsync();
|
||||
var u = await ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, translationId = m.UserOptions.TranslationId }).FirstAsync();
|
||||
context.Request.HttpContext.Items["AY_ROLES"] = u.roles;
|
||||
context.Request.HttpContext.Items["AY_USERNAME"] = u.name;
|
||||
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
|
||||
|
||||
@@ -28,9 +28,10 @@ namespace AyaNova.Biz
|
||||
u.Password = Hasher.hash(u.Salt, "l3tm3in");
|
||||
u.Roles = AuthorizationRoles.All;//AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
|
||||
|
||||
u.TranslationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;//Ensure primeTranslations is called first
|
||||
|
||||
u.UserType = UserType.Administrator;
|
||||
u.UserOptions = new UserOptions();
|
||||
u.UserOptions.TranslationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;//Ensure primeTranslations is called first
|
||||
await ct.User.AddAsync(u);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//See if any users exist with this translation selected in which case it's not deleteable
|
||||
if (await ct.User.AnyAsync(e => e.TranslationId == inObj.Id))
|
||||
if (await ct.UserOptions.AnyAsync(e => e.TranslationId == inObj.Id))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "object", "Can't be deleted in use by one or more Users");
|
||||
return;
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace AyaNova.Biz
|
||||
Active = o.Active,
|
||||
Name = o.Name,
|
||||
Roles = o.Roles,
|
||||
TranslationId = o.TranslationId,
|
||||
TranslationId = o.UserOptions.TranslationId,
|
||||
UserType = o.UserType,
|
||||
EmployeeNumber = o.EmployeeNumber,
|
||||
Notes = o.Notes,
|
||||
@@ -673,7 +673,7 @@ namespace AyaNova.Biz
|
||||
i.Roles = AuthorizationRoles.NoRole;
|
||||
|
||||
//temporary translation id to satisfy db settings
|
||||
i.TranslationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||
i.UserOptions.TranslationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||
|
||||
User o = await CreateAsync(i);
|
||||
if (HasErrors)
|
||||
@@ -754,7 +754,7 @@ namespace AyaNova.Biz
|
||||
break;
|
||||
}
|
||||
|
||||
u.TranslationId = await TranslationBiz.TranslationNameToIdStaticAsync(NewTranslationName, ct);
|
||||
u.UserOptions.TranslationId = await TranslationBiz.TranslationNameToIdStaticAsync(NewTranslationName, ct);
|
||||
|
||||
ct.SaveChanges();
|
||||
#endregion set translation
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace AyaNova.Models
|
||||
public string Salt { get; set; }
|
||||
[Required]
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
[Required]
|
||||
public long TranslationId { get; set; }
|
||||
// [Required]
|
||||
// public long TranslationId { get; set; }
|
||||
public string DlKey { get; set; }
|
||||
public DateTime? DlKeyExpire { get; set; }
|
||||
|
||||
|
||||
@@ -8,16 +8,18 @@ namespace AyaNova.Models
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
public long TranslationId { get; set; }
|
||||
|
||||
//-------------
|
||||
[EmailAddress]
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
/*
|
||||
Hexadecimal notation: #RGB[A]
|
||||
R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388.
|
||||
*/
|
||||
[MaxLength(12)]
|
||||
|
||||
/*
|
||||
Hexadecimal notation: #RGB[A]
|
||||
R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388.
|
||||
*/
|
||||
[MaxLength(12)]
|
||||
public string UiColor { get; set; }
|
||||
|
||||
//browser forced overrides
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace AyaNova.Util
|
||||
|
||||
//Add user table
|
||||
await ExecQueryAsync("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null unique, " +
|
||||
"login text not null, password text not null, salt text not null, roles integer not null, translationid bigint not null REFERENCES atranslation (id), " +
|
||||
"login text not null, password text not null, salt text not null, roles integer not null, " +
|
||||
"dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, customerid bigint, " +
|
||||
"headofficeid bigint, subvendorid bigint, customfields text, tags varchar(255) ARRAY)");
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace AyaNova.Util
|
||||
|
||||
//Add user options table
|
||||
await ExecQueryAsync("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, " +
|
||||
"userid bigint not null, languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor varchar(12) not null default '#000000')");
|
||||
"userid bigint not null, translationid bigint not null REFERENCES atranslation (id), languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor varchar(12) not null default '#000000')");
|
||||
|
||||
|
||||
//Prime the db with the default MANAGER account
|
||||
|
||||
@@ -582,7 +582,7 @@ namespace AyaNova.Util
|
||||
else
|
||||
u.Password = u.Login;
|
||||
u.Roles = roles;
|
||||
u.TranslationId = translationId;
|
||||
|
||||
u.UserType = userType;
|
||||
u.EmployeeNumber = "A-" + (454 + SeededUserCount).ToString() + "-Y";
|
||||
u.Notes = Fake.Lorem.Sentence();//Fake.Lorem.Paragraph(2);
|
||||
@@ -590,10 +590,11 @@ namespace AyaNova.Util
|
||||
u.Tags = RandomTags(Fake);
|
||||
//Children and relations
|
||||
u.UserOptions = new UserOptions();
|
||||
u.UserOptions.TranslationId = translationId;
|
||||
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
|
||||
u.UserOptions.Hour12 = true;
|
||||
u.UserOptions.CurrencyName = "USD";
|
||||
u.UserOptions.UiColor= Fake.Internet.Color();
|
||||
u.UserOptions.UiColor = Fake.Internet.Color();
|
||||
|
||||
|
||||
|
||||
@@ -625,7 +626,7 @@ namespace AyaNova.Util
|
||||
// WidgetBiz biz = WidgetBiz.GetBiz(ServiceProviderProvider.DBContext);
|
||||
|
||||
var f = new Bogus.Faker();
|
||||
|
||||
|
||||
|
||||
//RANDOM ROLES
|
||||
Array values = Enum.GetValues(typeof(UserType));
|
||||
|
||||
Reference in New Issue
Block a user