From 677c1b4c0abdfdfdc8f6ddd2b2219fc7123b245b Mon Sep 17 00:00:00 2001 From: Rob Kennedy Date: Tue, 6 Feb 2024 22:53:02 -0500 Subject: [PATCH] Created IUserInfo and modified classes to support. --- src/Security/ISubjectIdentity.cs | 8 ++-- src/Security/IUserInfo.cs | 45 ++++++++++++++++++++++ src/Security/MicroRoleModel.cs | 4 +- src/Security/MicroUserModel.cs | 14 ++++--- src/Security/MinimalRoleModel.cs | 2 +- src/Security/MinimalUserModel.cs | 4 +- src/Security/UserModel.cs | 6 +-- src/Server/MicroCreatedUpdaterModelBase.cs | 4 +- src/Server/TimeZoneModel.cs | 4 +- src/Talegen.Common.Models.csproj | 2 +- src/Talegen.Common.Models.xml | 38 +++++++++++++++--- 11 files changed, 103 insertions(+), 28 deletions(-) create mode 100644 src/Security/IUserInfo.cs diff --git a/src/Security/ISubjectIdentity.cs b/src/Security/ISubjectIdentity.cs index 14d4bca..902e66b 100644 --- a/src/Security/ISubjectIdentity.cs +++ b/src/Security/ISubjectIdentity.cs @@ -21,15 +21,15 @@ namespace Talegen.Common.Models.Security /// /// This interface implements the minimum properties for identification /// - public interface ISubjectIdentity + public interface ISubjectIdentity { /// - /// Gets the subject identity. + /// Gets or sets the unique identity of the subject. /// - Guid Id { get; set; } + TKey Id { get; set; } /// - /// Gets the subject name. + /// Gets or sets the name of the subject. /// string Name { get; set; } } diff --git a/src/Security/IUserInfo.cs b/src/Security/IUserInfo.cs new file mode 100644 index 0000000..da86d20 --- /dev/null +++ b/src/Security/IUserInfo.cs @@ -0,0 +1,45 @@ +/* + * + * (c) Copyright Talegen, LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +namespace Talegen.Common.Models.Security +{ + /// + /// This interface defines the minimum implementation of a user information object. + /// + /// Contains the type of the user identifier. + public interface IUserInfo : ISubjectIdentity + { + /// + /// Gets or sets the user email address. + /// + string Email { get; set; } + + /// + /// Gets or sets the user first name. + /// + string FirstName { get; set; } + + /// + /// Gets or sets the user last name. + /// + string LastName { get; set; } + + /// + /// Gets the full name of the user. + /// + string FullName { get; } + } +} diff --git a/src/Security/MicroRoleModel.cs b/src/Security/MicroRoleModel.cs index ba35f8c..ec04294 100644 --- a/src/Security/MicroRoleModel.cs +++ b/src/Security/MicroRoleModel.cs @@ -22,7 +22,7 @@ namespace Talegen.Common.Models.Security /// /// This class contains the bare minimum properties to represent a role in the interface. /// - public class MicroRoleModel : ISubjectIdentity + public class MicroRoleModel : ISubjectIdentity { /// /// Gets or sets the role identifier. @@ -35,6 +35,6 @@ public class MicroRoleModel : ISubjectIdentity /// /// The name. [Required] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/src/Security/MicroUserModel.cs b/src/Security/MicroUserModel.cs index 2ee03c4..4fcfef3 100644 --- a/src/Security/MicroUserModel.cs +++ b/src/Security/MicroUserModel.cs @@ -22,7 +22,7 @@ namespace Talegen.Common.Models.Security /// /// This class contains the bare minimum properties to represent a user in the interface. /// - public class MicroUserModel : ISubjectIdentity + public class MicroUserModel : IUserInfo { /// /// Gets or sets the unique identity of the user. @@ -33,27 +33,31 @@ public class MicroUserModel : ISubjectIdentity /// Gets or sets the user name of the user. /// [StringLength(100)] - public string Name { get; set; } + [Required] + public string Name { get; set; } = string.Empty; /// /// Gets or sets the user's e-mail address. /// [StringLength(100)] - public string Email { get; set; } + [Required] + public string Email { get; set; } = string.Empty; /// /// Gets or sets the first name. /// /// The first name. [StringLength(100)] - public string FirstName { get; set; } + [Required] + public string FirstName { get; set; } = string.Empty; /// /// Gets or sets the last name. /// /// The last name. [StringLength(100)] - public string LastName { get; set; } + [Required] + public string LastName { get; set; } = string.Empty; /// /// Gets the user full name. diff --git a/src/Security/MinimalRoleModel.cs b/src/Security/MinimalRoleModel.cs index 05f418f..8fc2821 100644 --- a/src/Security/MinimalRoleModel.cs +++ b/src/Security/MinimalRoleModel.cs @@ -44,7 +44,7 @@ public class MinimalRoleModel : MicroRoleModel /// /// Gets or sets the role description. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets or sets the type of the role. diff --git a/src/Security/MinimalUserModel.cs b/src/Security/MinimalUserModel.cs index b48db65..33e0905 100644 --- a/src/Security/MinimalUserModel.cs +++ b/src/Security/MinimalUserModel.cs @@ -27,12 +27,12 @@ public class MinimalUserModel : MicroUserModel /// /// Gets or sets the user's desired language. /// - public string Locale { get; set; } + public string? Locale { get; set; } /// /// Gets or sets the user's time zone. /// - public string TimeZone { get; set; } + public string? TimeZone { get; set; } /// /// Gets a value indicating whether the user is locked. diff --git a/src/Security/UserModel.cs b/src/Security/UserModel.cs index 5f374fb..9f1a43a 100644 --- a/src/Security/UserModel.cs +++ b/src/Security/UserModel.cs @@ -32,7 +32,7 @@ public class UserModel : MinimalUserModel /// /// Gets or sets the user model for the creator user. /// - public MinimalUserModel CreatedBy { get; set; } + public MinimalUserModel? CreatedBy { get; set; } /// /// Gets or sets the date time when the account was last updated. @@ -42,12 +42,12 @@ public class UserModel : MinimalUserModel /// /// Gets or sets the user model for the updating user. /// - public MinimalUserModel UpdatedBy { get; set; } + public MinimalUserModel? UpdatedBy { get; set; } /// /// Gets or sets the user notes. /// - public string Notes { get; set; } + public string? Notes { get; set; } /// /// Gets or sets a value indicating whether the user account is active. diff --git a/src/Server/MicroCreatedUpdaterModelBase.cs b/src/Server/MicroCreatedUpdaterModelBase.cs index b61ad14..e1d52b7 100644 --- a/src/Server/MicroCreatedUpdaterModelBase.cs +++ b/src/Server/MicroCreatedUpdaterModelBase.cs @@ -32,7 +32,7 @@ public abstract class MicroCreatedUpdaterModelBase /// /// Gets or sets the record creator model object. /// - public ISubjectIdentity? CreatedBy { get; set; } + public ISubjectIdentity? CreatedBy { get; set; } /// /// Gets or sets the record last updated date time. @@ -42,6 +42,6 @@ public abstract class MicroCreatedUpdaterModelBase /// /// Gets or sets the record updater model object. /// - public ISubjectIdentity? UpdatedBy { get; set; } + public ISubjectIdentity? UpdatedBy { get; set; } } } \ No newline at end of file diff --git a/src/Server/TimeZoneModel.cs b/src/Server/TimeZoneModel.cs index b1eb259..b5460b0 100644 --- a/src/Server/TimeZoneModel.cs +++ b/src/Server/TimeZoneModel.cs @@ -19,7 +19,7 @@ namespace Talegen.Common.Models.Server using System.ComponentModel.DataAnnotations; /// - /// This class represents a timezone model within an application. + /// This class represents a time zone model within an application. /// /// public class TimeZoneModel : MinimalTimeZoneModel @@ -28,7 +28,7 @@ public class TimeZoneModel : MinimalTimeZoneModel /// Gets or sets the long name of the time zone. /// [MaxLength(300)] - public string LongName { get; set; } + public string? LongName { get; set; } /// /// Gets or sets the numeric time offset. diff --git a/src/Talegen.Common.Models.csproj b/src/Talegen.Common.Models.csproj index d61d81e..a394b58 100644 --- a/src/Talegen.Common.Models.csproj +++ b/src/Talegen.Common.Models.csproj @@ -16,7 +16,7 @@ Updated packages and made minor changes to pagination results model to support query info and long total count. Assets\logo.ico false - 1.0.11.0 + 1.0.12.0 en enable Talegen.Common.Models diff --git a/src/Talegen.Common.Models.xml b/src/Talegen.Common.Models.xml index ece4932..391a562 100644 --- a/src/Talegen.Common.Models.xml +++ b/src/Talegen.Common.Models.xml @@ -733,19 +733,45 @@ The tag. - + This interface implements the minimum properties for identification - + - Gets the subject identity. + Gets or sets the unique identity of the subject. - + - Gets the subject name. + Gets or sets the name of the subject. + + + + + This interface defines the minimum implementation of a user information object. + + Contains the type of the user identifier. + + + + Gets or sets the user email address. + + + + + Gets or sets the user first name. + + + + + Gets or sets the user last name. + + + + + Gets the full name of the user. @@ -1565,7 +1591,7 @@ - This class represents a timezone model within an application. + This class represents a time zone model within an application.