User phone.

This commit is contained in:
Haiping Chen 2024-05-30 22:24:34 -05:00
parent b77e77e310
commit ee9abdd66b
7 changed files with 32 additions and 18 deletions

View file

@ -7,8 +7,9 @@ public class User
public string Id { get; set; } = string.Empty;
public string UserName { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string? LastName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string Salt { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Source { get; set; } = "internal";

View file

@ -6,6 +6,7 @@ using Microsoft.IdentityModel.Tokens;
using NanoidDotNet;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text.RegularExpressions;
namespace BotSharp.Core.Users.Services;
@ -55,6 +56,10 @@ public class UserService : IUserService
record = user;
record.Email = user.Email?.ToLower();
if (user.Phone != null)
{
record.Phone = "+" + Regex.Match(user.Phone, @"\d+").Value;
}
record.Salt = Guid.NewGuid().ToString("N");
record.Password = Utilities.HashText(user.Password, record.Salt);

View file

@ -4,10 +4,11 @@ namespace BotSharp.OpenAPI.ViewModels.Users;
public class UserCreationModel
{
public string UserName { get; set; } = string.Empty;
public string? UserName { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string? LastName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string Password { get; set; } = string.Empty;
public string Role { get; set; } = UserRole.Client;
@ -19,6 +20,7 @@ public class UserCreationModel
FirstName = FirstName,
LastName = LastName,
Email = Email,
Phone = Phone,
Password = Password,
Role = Role
};

View file

@ -5,14 +5,15 @@ namespace BotSharp.OpenAPI.ViewModels.Users;
public class UserViewModel
{
public string Id { get; set; }
public string Id { get; set; } = null!;
[JsonPropertyName("user_name")]
public string UserName { get; set; }
public string UserName { get; set; } = null!;
[JsonPropertyName("first_name")]
public string FirstName { get; set; }
public string FirstName { get; set; } = null!;
[JsonPropertyName("last_name")]
public string LastName { get; set; }
public string Email { get; set; }
public string? LastName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string Role { get; set; } = UserRole.Client;
[JsonPropertyName("full_name")]
public string FullName => $"{FirstName} {LastName}".Trim();
@ -44,6 +45,7 @@ public class UserViewModel
FirstName = user.FirstName,
LastName = user.LastName,
Email = user.Email,
Phone = user.Phone,
Role = user.Role,
Source = user.Source,
ExternalId = user.ExternalId,

View file

@ -4,15 +4,16 @@ namespace BotSharp.Plugin.MongoStorage.Collections;
public class UserDocument : MongoBase
{
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Salt { get; set; }
public string Password { get; set; }
public string UserName { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string? LastName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string Salt { get; set; } = null!;
public string Password { get; set; } = null!;
public string Source { get; set; } = "internal";
public string? ExternalId { get; set; }
public string Role { get; set; }
public string Role { get; set; } = null!;
public string? VerificationCode { get; set; }
public bool Verified { get; set; }
public DateTime CreatedTime { get; set; }
@ -27,6 +28,7 @@ public class UserDocument : MongoBase
FirstName = FirstName,
LastName = LastName,
Email = Email,
Phone = Phone,
Password = Password,
Salt = Salt,
Source = Source,

View file

@ -37,6 +37,7 @@ public partial class MongoRepository
Salt = user.Salt,
Password = user.Password,
Email = user.Email,
Phone = user.Phone,
Source = user.Source,
ExternalId = user.ExternalId,
Role = user.Role,

View file

@ -31,7 +31,8 @@ public partial class PlaywrightWebDriver
if (response.Status == 200)
{
result.Body = await page.ContentAsync();
// Disable this due to performance issue, some page is too large
// result.Body = await page.InnerHTMLAsync("body");
result.IsSuccess = true;
}
else