add refresh token
This commit is contained in:
parent
6ced7f4884
commit
0d5b708044
|
|
@ -53,11 +53,12 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Global
|
|||
public string JwtAudience { get; set; }
|
||||
public bool JwtValidateIssuer { get; set; }
|
||||
public bool JwtValidateAudience { get; set; }
|
||||
public int RefreshTokenDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folder management
|
||||
/// </summary>
|
||||
public string UploadFolder { get; set; }
|
||||
/// <summary>
|
||||
/// Folder management
|
||||
/// </summary>
|
||||
public string UploadFolder { get; set; }
|
||||
public string ProfileImageFolder { get; set; }
|
||||
public string ReportFolder { get; set; }
|
||||
public string FileProcessFolder { get; set; }
|
||||
|
|
@ -85,6 +86,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Global
|
|||
public string EmailSenderIp { get; set; }
|
||||
public string EmailSenderId { get; set; }
|
||||
|
||||
|
||||
private string _emailSenderPwd;
|
||||
public string EmailSenderPwd
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
|
|||
public const int SuperUser_Id = -9;
|
||||
public const string SuperUser_LoginId = "superuser";
|
||||
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
public string Password { get; set; }
|
||||
public DateTime? LogoutTime { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public EnumStatus Status { get; set; }
|
||||
|
|
@ -25,7 +26,10 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
|
|||
public string SchemeName { get; set; }
|
||||
public string MenuLayout { get; set; }
|
||||
public bool IsLocked { get; set; }
|
||||
}
|
||||
public EnumLoginStatus LoginStatus { get; set; }
|
||||
public DateTime? NextLoginTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class LoginHistory
|
||||
{
|
||||
|
|
@ -38,13 +42,15 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
|
|||
|
||||
public class AccessLog
|
||||
{
|
||||
public int AccessLogId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
public DateTime LoginTime { get; set; }
|
||||
public string LoginIp { get; set; }
|
||||
public DateTime? LogoutTime { get; set; }
|
||||
public string LogoutIp { get; set; }
|
||||
public string LoginStatus { get; set; }
|
||||
}
|
||||
public EnumLoginStatus LoginStatus { get; set; }
|
||||
}
|
||||
|
||||
public class UserForceLogout
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||
|
||||
public class IntegrstionLoginRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 3, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 5, ErrorMessage = "Password must be between 1 and 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class IntegrationRefreshTokenRequest
|
||||
{
|
||||
public string RefreshToken { get; set; }
|
||||
}
|
||||
|
||||
public class InsertRefreshTokenRequest : RefreshToken
|
||||
{
|
||||
public string RefreshToken { get; set; }
|
||||
}
|
||||
|
||||
public class RevokedRefreshTokenRequest
|
||||
{
|
||||
public string RefreshToken { get; set; }
|
||||
}
|
||||
|
||||
public class GenerateRefreshTokenRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
}
|
||||
|
|
@ -3,219 +3,218 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems;
|
||||
|
||||
public class FindAccountRequest
|
||||
{
|
||||
public class FindAccountRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 200, MinimumLength = 4, ErrorMessage = "Login Id or Email address or Mobile number must be between 4 and 100 characters.")]
|
||||
public string AccountId { get; set; }
|
||||
}
|
||||
|
||||
public class LoginRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 4, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string AppId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 8, MinimumLength = 5, ErrorMessage = "Version must be 5 and 8 digits (Example: 0.0.0 or 99.99.99)")]
|
||||
public string AppVersion { get; set; }
|
||||
|
||||
public bool AttendanceLogin { get; set; }
|
||||
public string HostName { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public string MacAddress { get; set; }
|
||||
public string LoginRemarks { get; set; }
|
||||
}
|
||||
|
||||
public class OtpValidationRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public EnumAuthenticationMethod AuthMethod { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(6, MinimumLength = 6, ErrorMessage = "Otp must be 6 digit number.")]
|
||||
public string OtpCode { get; set; }
|
||||
}
|
||||
|
||||
public class ByUserIdRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
|
||||
public class SendPasswordRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 300, MinimumLength = 1, ErrorMessage = "User Id is required.")]
|
||||
public string UserId { get; set; }
|
||||
public string MobileNo { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
}
|
||||
|
||||
public class UserUnlockRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Login Id must be between 1 and 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
}
|
||||
|
||||
public class ResetPasswordRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Confirm Password must be between 1 and 30 characters.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
|
||||
public class PasswordChangeRequest : ResetPasswordRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Old Password must be between 1 and 30 characters.")]
|
||||
public string OldPassword { get; set; }
|
||||
}
|
||||
|
||||
public class LogoutRequest
|
||||
{
|
||||
public int LogId { get; set; }
|
||||
public bool AttendanceLogout { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public string MacAddress { get; set; }
|
||||
public string HostName { get; set; }
|
||||
public string LogoutRemarks { get; set; }
|
||||
}
|
||||
|
||||
public class UserThemeRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Menu Layout must be between 1 to 15 characters.")]
|
||||
public string MenuLayout { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Theme Name must be between 1 to 15 characters.")]
|
||||
public string ThemeName { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(10, MinimumLength = 1, ErrorMessage = "Scheme Name must be between 1 to 10 characters.")]
|
||||
public string SchemeName { get; set; }
|
||||
}
|
||||
|
||||
public class UserRequestBase
|
||||
{
|
||||
[Required, NotNull, StringLength(30, MinimumLength = 3, ErrorMessage = "Login Id must be between 3 to 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(75, MinimumLength = 3, ErrorMessage = "User Name must be between 3 to 75 characters.")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(50, MinimumLength = 0, ErrorMessage = "Designation must be between 0 to 50 characters.")]
|
||||
public string Designation { get; set; }
|
||||
|
||||
[StringLength(15, MinimumLength = 11, ErrorMessage = "Mobile number must be 11 characters.")]
|
||||
[RegularExpression(@"^[01]{2}[123456789]{1}[0-9]{8}$", ErrorMessage = "Mobile number is invalid.")]
|
||||
public string MobileNo { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(100, MinimumLength = 5, ErrorMessage = "Email address must be between 5 to 100 characters.")]
|
||||
[RegularExpression(@"^(([a-zA-Z0-9_\-\.]+)\@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$", ErrorMessage = "Email address is invalid.")]
|
||||
public string EmailAddress { get; set; } = string.Empty;
|
||||
public bool AuthReqAtlogin { get; set; }
|
||||
public bool NeverExpire { get; set; }
|
||||
public bool DbOnStartup { get; set; }
|
||||
public bool DisallowMultiLogin { get; set; }
|
||||
public EnumStatus Status { get; set; }
|
||||
public short SeqId { get; set; }
|
||||
public bool ViewToAll { get; set; }
|
||||
public bool CanUseAttendanceSystem { get; set; }
|
||||
public EnumAuthenticationMethod AuthMethod { get; set; }
|
||||
public EnumAccessStatus AccessStatus { get; set; }
|
||||
public List<int> GroupIds { get; set; }
|
||||
}
|
||||
|
||||
public class UserRequest : UserRequestBase
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string AuthKey { get; set; }
|
||||
}
|
||||
|
||||
public class NewUserRequest : UserRequestBase
|
||||
{
|
||||
public int? EmployeeId { get; set; }
|
||||
public string EmployeeCode { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(30, MinimumLength = 1, ErrorMessage = "User Name must be between 1 to 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class UserSearchRequest : ValueStatusAndPageAndSortSearchRequest
|
||||
{
|
||||
public bool CheckOwner { get; set; }
|
||||
}
|
||||
|
||||
public class ForceUserLogoutRequest
|
||||
{
|
||||
public List<int> UserIds { get; set; }
|
||||
}
|
||||
|
||||
public class ByUserAttributesRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
|
||||
public int ClientType { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateMyInfoRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Employee Id must be 1 to 2147483647")]
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[NotNull, StringLength(120, MinimumLength = 0, ErrorMessage = "Address be between 0 to 120 characters.")]
|
||||
public string Address { get; set; }
|
||||
|
||||
public string ContactNo { get; set; }
|
||||
}
|
||||
|
||||
public class UserAttributesRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
|
||||
public int ClientType { get; set; }
|
||||
public List<string> UkIds { get; set; }
|
||||
}
|
||||
public class AccessLogSearchRequest
|
||||
{
|
||||
public int AccessType { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
|
||||
public class ByTeamSpaceAndBasicUserRequest
|
||||
{
|
||||
public int TeamSpaceId { get; set; }
|
||||
public int ProjectId { get; set; }
|
||||
}
|
||||
|
||||
public class BasicUserByTeamSpaceRequest : ByTeamSpaceAndBasicUserRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
|
||||
public class BasicUserSearchRequest : BasicUserByTeamSpaceRequest
|
||||
{
|
||||
public bool ApplyFilter { get; set; }
|
||||
}
|
||||
|
||||
public class UserLimitAuthorizeRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
public decimal MaxAuthorizeAmount { get; set; }
|
||||
}
|
||||
|
||||
public class PayslipRequest
|
||||
{
|
||||
[Required, NotNull]
|
||||
public DateTime YearMonth { get; set; }
|
||||
}
|
||||
[Required, NotNull, StringLength(maximumLength: 200, MinimumLength = 4, ErrorMessage = "Login Id or Email address or Mobile number must be between 4 and 100 characters.")]
|
||||
public string AccountId { get; set; }
|
||||
}
|
||||
|
||||
public class LoginRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 4, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
|
||||
public string AppId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 8, MinimumLength = 5, ErrorMessage = "Version must be 5 and 8 digits (Example: 0.0.0 or 99.99.99)")]
|
||||
public string AppVersion { get; set; }
|
||||
|
||||
public bool AttendanceLogin { get; set; }
|
||||
public string HostName { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public string MacAddress { get; set; }
|
||||
public string LoginRemarks { get; set; }
|
||||
}
|
||||
|
||||
public class OtpValidationRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public EnumAuthenticationMethod AuthMethod { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(6, MinimumLength = 6, ErrorMessage = "Otp must be 6 digit number.")]
|
||||
public string OtpCode { get; set; }
|
||||
}
|
||||
|
||||
public class ByUserIdRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
|
||||
public class SendPasswordRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 300, MinimumLength = 1, ErrorMessage = "User Id is required.")]
|
||||
public string UserId { get; set; }
|
||||
public string MobileNo { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
}
|
||||
|
||||
public class UserUnlockRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Login Id must be between 1 and 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
}
|
||||
|
||||
public class ResetPasswordRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Confirm Password must be between 1 and 30 characters.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
|
||||
public class PasswordChangeRequest : ResetPasswordRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Old Password must be between 1 and 30 characters.")]
|
||||
public string OldPassword { get; set; }
|
||||
}
|
||||
|
||||
public class LogoutRequest
|
||||
{
|
||||
public int LogId { get; set; }
|
||||
public bool AttendanceLogout { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public string MacAddress { get; set; }
|
||||
public string HostName { get; set; }
|
||||
public string LogoutRemarks { get; set; }
|
||||
}
|
||||
|
||||
public class UserThemeRequest
|
||||
{
|
||||
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Menu Layout must be between 1 to 15 characters.")]
|
||||
public string MenuLayout { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Theme Name must be between 1 to 15 characters.")]
|
||||
public string ThemeName { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(10, MinimumLength = 1, ErrorMessage = "Scheme Name must be between 1 to 10 characters.")]
|
||||
public string SchemeName { get; set; }
|
||||
}
|
||||
|
||||
public class UserRequestBase
|
||||
{
|
||||
[Required, NotNull, StringLength(30, MinimumLength = 3, ErrorMessage = "Login Id must be between 3 to 30 characters.")]
|
||||
public string LoginId { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(75, MinimumLength = 3, ErrorMessage = "User Name must be between 3 to 75 characters.")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(50, MinimumLength = 0, ErrorMessage = "Designation must be between 0 to 50 characters.")]
|
||||
public string Designation { get; set; }
|
||||
|
||||
[StringLength(15, MinimumLength = 11, ErrorMessage = "Mobile number must be 11 characters.")]
|
||||
[RegularExpression(@"^[01]{2}[123456789]{1}[0-9]{8}$", ErrorMessage = "Mobile number is invalid.")]
|
||||
public string MobileNo { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(100, MinimumLength = 5, ErrorMessage = "Email address must be between 5 to 100 characters.")]
|
||||
[RegularExpression(@"^(([a-zA-Z0-9_\-\.]+)\@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$", ErrorMessage = "Email address is invalid.")]
|
||||
public string EmailAddress { get; set; } = string.Empty;
|
||||
public bool AuthReqAtlogin { get; set; }
|
||||
public bool NeverExpire { get; set; }
|
||||
public bool DbOnStartup { get; set; }
|
||||
public bool DisallowMultiLogin { get; set; }
|
||||
public EnumStatus Status { get; set; }
|
||||
public short SeqId { get; set; }
|
||||
public bool ViewToAll { get; set; }
|
||||
public bool CanUseAttendanceSystem { get; set; }
|
||||
public EnumAuthenticationMethod AuthMethod { get; set; }
|
||||
public EnumAccessStatus AccessStatus { get; set; }
|
||||
public List<int> GroupIds { get; set; }
|
||||
}
|
||||
|
||||
public class UserRequest : UserRequestBase
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string AuthKey { get; set; }
|
||||
}
|
||||
|
||||
public class NewUserRequest : UserRequestBase
|
||||
{
|
||||
public int? EmployeeId { get; set; }
|
||||
public string EmployeeCode { get; set; }
|
||||
|
||||
[Required, NotNull, StringLength(30, MinimumLength = 1, ErrorMessage = "User Name must be between 1 to 30 characters.")]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class UserSearchRequest : ValueStatusAndPageAndSortSearchRequest
|
||||
{
|
||||
public bool CheckOwner { get; set; }
|
||||
}
|
||||
|
||||
public class ForceUserLogoutRequest
|
||||
{
|
||||
public List<int> UserIds { get; set; }
|
||||
}
|
||||
|
||||
public class ByUserAttributesRequest : ByUserIdRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
|
||||
public int ClientType { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateMyInfoRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Employee Id must be 1 to 2147483647")]
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[NotNull, StringLength(120, MinimumLength = 0, ErrorMessage = "Address be between 0 to 120 characters.")]
|
||||
public string Address { get; set; }
|
||||
|
||||
public string ContactNo { get; set; }
|
||||
}
|
||||
|
||||
public class UserAttributesRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
|
||||
public int ClientType { get; set; }
|
||||
public List<string> UkIds { get; set; }
|
||||
}
|
||||
public class AccessLogSearchRequest
|
||||
{
|
||||
public int AccessType { get; set; }
|
||||
public string LoginId { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
|
||||
public class ByTeamSpaceAndBasicUserRequest
|
||||
{
|
||||
public int TeamSpaceId { get; set; }
|
||||
public int ProjectId { get; set; }
|
||||
}
|
||||
|
||||
public class BasicUserByTeamSpaceRequest : ByTeamSpaceAndBasicUserRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
|
||||
public class BasicUserSearchRequest : BasicUserByTeamSpaceRequest
|
||||
{
|
||||
public bool ApplyFilter { get; set; }
|
||||
}
|
||||
|
||||
public class UserLimitAuthorizeRequest
|
||||
{
|
||||
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
public decimal MaxAuthorizeAmount { get; set; }
|
||||
}
|
||||
|
||||
public class PayslipRequest
|
||||
{
|
||||
[Required, NotNull]
|
||||
public DateTime YearMonth { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||
|
||||
public class IntegrationLoginResponse
|
||||
{
|
||||
public string LoginId { get; set; }
|
||||
public string AccessToken { get; set; } = string.Empty;
|
||||
public string RefreshToken { get; set; } = string.Empty;
|
||||
public DateTime AccessTokenExpiry { get; set; }
|
||||
}
|
||||
|
||||
public class RefreshTokenResponse
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string TokenHash { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public DateTime ExpiredAt { get; set; }
|
||||
public DateTime? RevokedAt { get; set; }
|
||||
public string DeviceInfo { get; set; }
|
||||
}
|
||||
|
||||
public class GenerateRefreshTokenResponse
|
||||
{
|
||||
public string RefreshToken { get; set; }
|
||||
public DateTime ExpireTime { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
|
||||
|
||||
public interface IRefreshTokenService
|
||||
{
|
||||
Task<RefreshTokenResponse?> GetByTokenHashAsync(string tokenHash);
|
||||
Task<bool> AddAsync(InsertRefreshTokenRequest refreshToken);
|
||||
Task<bool> RevokeAsync(RevokedRefreshTokenRequest token);
|
||||
Task<bool> RevokeAllForUserAsync(int userId);
|
||||
Task<GenerateRefreshTokenResponse> GenerateRefreshToken(GenerateRefreshTokenRequest request);
|
||||
}
|
||||
|
|
@ -34,7 +34,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems
|
|||
Task<FindAccountResponse> FindAccountAsync(string accountId);
|
||||
Task<UserAuthorizeLimitResponse> GetAuthorizeLimitAsync(int userId);
|
||||
Task<UserAttributesResponse> GetAttributesAsync(int userId, int clientType);
|
||||
Task<DashboardDataResponse> GetDashboardData(int userId, bool canViewLeave, bool canViewLate, bool canViewClientVisit, bool canViewHomeOffice, bool viewAll);
|
||||
|
||||
Task<int> LoadNotificationCountAsync(int userId);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,226 @@
|
|||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml.VariantTypes;
|
||||
using Ease.NetCore.DataAccess;
|
||||
using Ease.NetCore.DataAccess.SQL;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Auth;
|
||||
|
||||
public class RefreshTokenService : IRefreshTokenService
|
||||
{
|
||||
private readonly AppSettings _settings;
|
||||
public RefreshTokenService(IOptions<AppSettings> settings)
|
||||
{
|
||||
_settings = settings.Value;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> AddAsync(InsertRefreshTokenRequest refreshToken)
|
||||
{
|
||||
bool returnValue = false;
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||
await AddAsync(tc, refreshToken);
|
||||
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(e.Message, e);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
private async Task<bool> AddAsync( TransactionContext tc, InsertRefreshTokenRequest refreshToken)
|
||||
{
|
||||
bool returnValue = false;
|
||||
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@UserId", pType: SqlDbType.VarChar, pValue: refreshToken.UserId),
|
||||
SqlHelperExtension.CreateInParam(pName: "@TokenHash", pType: SqlDbType.VarChar, pValue: refreshToken.TokenHash),
|
||||
SqlHelperExtension.CreateInParam(pName: "@IpAddress", pType: SqlDbType.VarChar, pValue: refreshToken.IpAddress),
|
||||
SqlHelperExtension.CreateInParam(pName: "@CreatedAt", pType: SqlDbType.DateTime, pValue: DateTime.Now),
|
||||
SqlHelperExtension.CreateInParam(pName: "@ExpiredAt", pType: SqlDbType.DateTime, pValue: DateTime.Now.AddMinutes(_settings.RefreshTokenDuration)),
|
||||
];
|
||||
_ = await tc.ExecuteNonQuerySpAsync(spName: "dbo.InsertRefreshToken", parameterValues: p);
|
||||
|
||||
returnValue = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(e.Message, e);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
public async Task<RefreshTokenResponse> GetByTokenHashAsync(string tokenHash)
|
||||
{
|
||||
RefreshTokenResponse response = new();
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@TokenHash", pType: SqlDbType.VarChar, pValue: tokenHash, size: 10)
|
||||
];
|
||||
|
||||
using (IDataReader dr =await tc.ExecuteReaderSpAsync("dbo.GetRefreshTokenByTokenHash", parameterValues: p))
|
||||
{
|
||||
if (dr.Read())
|
||||
{
|
||||
response.UserId = dr.GetString(0);
|
||||
response.TokenHash = dr.GetString(1);
|
||||
response.IpAddress = dr.GetString(2);
|
||||
response.ExpiredAt = dr.GetDateTime(3);
|
||||
response.RevokedAt = dr.IsDBNull(4) ? null: dr.GetDateTime(4);
|
||||
}
|
||||
dr.Close();
|
||||
}
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception ie)
|
||||
{
|
||||
tc?.HandleError();
|
||||
|
||||
throw DBCustomError.GenerateCustomError(ie);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(e.Message, e);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<bool> RevokeAllForUserAsync(int userId)
|
||||
{
|
||||
bool returnValue = false;
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@UserId", pType: SqlDbType.Int, pValue: userId)
|
||||
];
|
||||
_ = await tc.ExecuteNonQuerySpAsync(spName: "dbo.RevokedAllRefreshToken", parameterValues: p);
|
||||
|
||||
returnValue = true;
|
||||
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception ie)
|
||||
{
|
||||
tc?.HandleError();
|
||||
|
||||
throw DBCustomError.GenerateCustomError(ie);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(e.Message, e);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public async Task<bool> RevokeAsync(RevokedRefreshTokenRequest token)
|
||||
{
|
||||
bool returnValue = false;
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@RefreshToken", pType: SqlDbType.NVarChar, pValue: token.RefreshToken)
|
||||
];
|
||||
_ = await tc.ExecuteNonQuerySpAsync(spName: "dbo.RevokedAllRefreshToken", parameterValues: p);
|
||||
|
||||
returnValue = true;
|
||||
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception ie)
|
||||
{
|
||||
tc?.HandleError();
|
||||
|
||||
throw DBCustomError.GenerateCustomError(ie);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidOperationException(e.Message, e);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public async Task<GenerateRefreshTokenResponse> GenerateRefreshToken()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
// ----- private helpers -----
|
||||
|
||||
private async Task<LoginResponse> IssueTokensAsync(TransactionContext tc, User user, string deviceInfo, string ipAddress)
|
||||
{
|
||||
var refreshToken = new InsertRefreshTokenRequest
|
||||
{
|
||||
UserId = user.UserId,
|
||||
TokenHash = HashToken(GenerateRowToken()),
|
||||
IpAddress = ipAddress,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
ExpiresAt = DateTime.UtcNow.AddDays(_settings.RefreshTokenDuration)
|
||||
};
|
||||
|
||||
await AddAsync(tc,refreshToken);
|
||||
|
||||
return new LoginResponse
|
||||
{
|
||||
AccessToken = accessToken,
|
||||
RefreshToken = rawRefreshToken,
|
||||
AccessTokenExpiry = DateTime.UtcNow.AddMinutes(_settings.AccessTokenExpiryMinutes)
|
||||
};
|
||||
}
|
||||
|
||||
private static string HashToken(string token)
|
||||
{
|
||||
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(token));
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
private string GenerateRowToken()
|
||||
{
|
||||
var bytes = new byte[64];
|
||||
using var rng = RandomNumberGenerator.Create();
|
||||
rng.GetBytes(bytes);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -3,7 +3,6 @@ using OnlineSalesAutoCrop.CoreAPI.Configurations;
|
|||
using OnlineSalesAutoCrop.CoreAPI.Models;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Setups;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Requests;
|
||||
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Setups;
|
||||
|
|
@ -19,7 +18,6 @@ using Microsoft.AspNetCore.SignalR;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.Reporting.NETCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices;
|
||||
|
|
@ -51,7 +49,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
|
|||
[ValidateAntiForgeryToken]
|
||||
[Route("api/v{version:apiVersion}/users")]
|
||||
|
||||
public class UserController(IUserService service, IOptions<AppSettings> appSettings, IEaseCache cache, ILogger<UserController> logger, IHubContext<NotificationHub, INotificationHub> hub) : ControllerBase
|
||||
public class UserController(IUserService service, IOptions<AppSettings> appSettings, IEaseCache cache, ILogger<AuthController> logger, IHubContext<NotificationHub, INotificationHub> hub) : ControllerBase
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IEaseCache _cache = cache;
|
||||
|
|
|
|||
|
|
@ -27,51 +27,6 @@
|
|||
"CorsMethods": "POST",
|
||||
"CorsOrigins": "http://localhost:4200,http://localhost:5050,http://localhost:7777",
|
||||
"DbConfig": [
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "Data Source=103.197.204.162,3341;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysUser;Password=OnlineSalesAutoCrop;Encrypt=false;",
|
||||
"EncryptKey": "",
|
||||
"Key": "spadb1",
|
||||
"Provider": "sql",
|
||||
"SqlSyntax": "SQL"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "V3DJ2Y3A4Tzp9y3WKGINJWSjQdvo7QxL+U4VfYkfrfbZB8b4sNPPgJM5J17wFLAmaOzvDmGBK0hN5TX8iOYEdntndR1isy1SqPZgoyEshX+87OQYsKVKrl85foY49BJGB75CdAuVXoizsLsDrKcNzw==",
|
||||
"Key": "spadb2",
|
||||
"Provider": "sql",
|
||||
"SqlSyntax": "SQL",
|
||||
"EncryptKey": "RWFzZURoMTk5MlRvMjAyMw=="
|
||||
}
|
||||
},
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "M6aE4Nur0oHi9ddFe/IC/VlXYQTfJSafpWzjFeSHfNrozfGF/ZJMBLEMLe9SwVt0SUisTwL+5v5l1TYsYkpn9Dgo+K2H2X+OMsql1pf1vww=",
|
||||
"Key": "spadb3",
|
||||
"Provider": "sql",
|
||||
"SqlSyntax": "SQL",
|
||||
"EncryptKey": "RWFzZURoMTk5MlRvMjAyMw=="
|
||||
}
|
||||
},
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "Server=Russel;Initial Catalog=OnlineSalesAutoCrop;Integrated Security=True;TrustServerCertificate=True;Encrypt=true;",
|
||||
"Key": "spadb4",
|
||||
"Provider": "sql",
|
||||
"SqlSyntax": "SQL",
|
||||
"EncryptKey": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "Data Source=100.100.100.80;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysuser;Password=[password];Encrypt=false;",
|
||||
"Key": "spadb6",
|
||||
"Provider": "sql",
|
||||
"SqlSyntax": "SQL",
|
||||
"EncryptKey": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ConnectionNode": {
|
||||
"ConnectionString": "Data Source=210.4.65.222,3341;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysUser;Password=OnlineSalesAutoCrop;Encrypt=false;",
|
||||
|
|
@ -128,7 +83,8 @@
|
|||
"WaAccountSid": "AC0138ad79a532f653c35072dad10e52b9",
|
||||
"WaAuthToken": "024a6897584671d9f9fa588d7c94aa96",
|
||||
"WaMsgSvcSid": "MG8401d33a9a3b2aea95619bda3e5757b5",
|
||||
"WaSenderId": "+8801326755660"
|
||||
"WaSenderId": "+8801326755660",
|
||||
"RefreshTokenDuration": "15"
|
||||
},
|
||||
|
||||
"MenuSettings": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user