Add UserType.
This commit is contained in:
parent
0f37ef88f6
commit
5fceb2cd4f
|
|
@ -13,9 +13,9 @@ public class UserRole
|
|||
public const string CSR = "csr";
|
||||
|
||||
/// <summary>
|
||||
/// Client
|
||||
/// Authorized user
|
||||
/// </summary>
|
||||
public const string Client = "client";
|
||||
public const string User = "user";
|
||||
|
||||
/// <summary>
|
||||
/// Back office operations
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
namespace BotSharp.Abstraction.Users.Enums;
|
||||
|
||||
public class UserType
|
||||
{
|
||||
public const string Internal = "internal";
|
||||
public const string Client = "client";
|
||||
public const string Affiliate = "affiliate";
|
||||
}
|
||||
|
|
@ -14,7 +14,11 @@ public class User
|
|||
public string Password { get; set; } = string.Empty;
|
||||
public string Source { get; set; } = "internal";
|
||||
public string? ExternalId { get; set; }
|
||||
public string Role { get; set; } = UserRole.Client;
|
||||
/// <summary>
|
||||
/// internal, client, affiliate
|
||||
/// </summary>
|
||||
public string Type { get; set; } = UserType.Client;
|
||||
public string Role { get; set; } = UserRole.User;
|
||||
public string? VerificationCode { get; set; }
|
||||
public bool Verified { get; set; }
|
||||
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
|
||||
_historyStates = _db.GetConversationStates(conversationId);
|
||||
var dialogs = _db.GetConversationDialogs(conversationId);
|
||||
var userDialogs = dialogs.Where(x => x.MetaData?.Role == AgentRole.User || x.MetaData?.Role == UserRole.Client)
|
||||
var userDialogs = dialogs.Where(x => x.MetaData?.Role == AgentRole.User || x.MetaData?.Role == UserRole.User)
|
||||
.GroupBy(x => x.MetaData?.MessageId)
|
||||
.Select(g => g.First())
|
||||
.OrderBy(x => x.MetaData?.CreateTime)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Users.Enums;
|
||||
using BotSharp.Abstraction.Users.Models;
|
||||
using BotSharp.Abstraction.Users.Settings;
|
||||
using BotSharp.OpenAPI.ViewModels.Users;
|
||||
|
|
@ -137,6 +138,7 @@ public class UserService : IUserService
|
|||
Source = user.Source,
|
||||
ExternalId = user.ExternalId,
|
||||
Password = user.Password,
|
||||
Type = user.Type,
|
||||
};
|
||||
await CreateUser(record);
|
||||
}
|
||||
|
|
@ -190,6 +192,7 @@ public class UserService : IUserService
|
|||
new Claim(JwtRegisteredClaimNames.FamilyName, user?.LastName ?? string.Empty),
|
||||
new Claim("source", user.Source),
|
||||
new Claim("external_id", user.ExternalId ?? string.Empty),
|
||||
new Claim("type", user.Type ?? UserType.Client),
|
||||
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
|
||||
new Claim("phone", user.Phone ?? string.Empty)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ public class UserCreationModel
|
|||
public string? Email { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = UserRole.Client;
|
||||
public string Type { get; set; } = UserType.Client;
|
||||
public string Role { get; set; } = UserRole.User;
|
||||
|
||||
public User ToUser()
|
||||
{
|
||||
|
|
@ -22,7 +23,8 @@ public class UserCreationModel
|
|||
Email = Email,
|
||||
Phone = Phone,
|
||||
Password = Password,
|
||||
Role = Role
|
||||
Role = Role,
|
||||
Type = Type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ public class UserViewModel
|
|||
public string? LastName { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string Role { get; set; } = UserRole.Client;
|
||||
public string Type { get; set; } = UserType.Client;
|
||||
public string Role { get; set; } = UserRole.User;
|
||||
[JsonPropertyName("full_name")]
|
||||
public string FullName => $"{FirstName} {LastName}".Trim();
|
||||
public string Source { get; set; }
|
||||
|
|
@ -34,6 +35,7 @@ public class UserViewModel
|
|||
{
|
||||
FirstName = "Unknown",
|
||||
LastName = "Anonymous",
|
||||
Type = UserType.Client,
|
||||
Role = AgentRole.User
|
||||
};
|
||||
}
|
||||
|
|
@ -46,6 +48,7 @@ public class UserViewModel
|
|||
LastName = user.LastName,
|
||||
Email = user.Email,
|
||||
Phone = user.Phone,
|
||||
Type = user.Type,
|
||||
Role = user.Role,
|
||||
Source = user.Source,
|
||||
ExternalId = user.ExternalId,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Users.Enums;
|
||||
using BotSharp.Abstraction.Users.Models;
|
||||
|
||||
namespace BotSharp.Plugin.MongoStorage.Collections;
|
||||
|
|
@ -13,6 +14,7 @@ public class UserDocument : MongoBase
|
|||
public string Password { get; set; } = null!;
|
||||
public string Source { get; set; } = "internal";
|
||||
public string? ExternalId { get; set; }
|
||||
public string Type { get; set; } = UserType.Client;
|
||||
public string Role { get; set; } = null!;
|
||||
public string? VerificationCode { get; set; }
|
||||
public bool Verified { get; set; }
|
||||
|
|
@ -33,6 +35,7 @@ public class UserDocument : MongoBase
|
|||
Salt = Salt,
|
||||
Source = Source,
|
||||
ExternalId = ExternalId,
|
||||
Type = Type,
|
||||
Role = Role,
|
||||
VerificationCode = VerificationCode,
|
||||
Verified = Verified,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public partial class MongoRepository
|
|||
Source = user.Source,
|
||||
ExternalId = user.ExternalId,
|
||||
Role = user.Role,
|
||||
Type = user.Type,
|
||||
VerificationCode = user.VerificationCode,
|
||||
Verified = user.Verified,
|
||||
CreatedTime = DateTime.UtcNow,
|
||||
|
|
|
|||
Loading…
Reference in a new issue