Owneat Technical Guide main Help

Class User

Namespace: Identity.Domain.Aggregates.UserAggregate
Assembly: Identity.Domain.dll

User class that define authentication users, this entity is the identity one.

[Table("Users")] [Index("Username", new string[] { }, IsUnique = true)] [Index("Email", new string[] { }, IsUnique = true)] public class User : Entity, IAggregateRoot, IAuditable

Inheritance

object ← Entity ← User

Implements

IAggregateRoot, IAuditable

Inherited Members

Entity.Id, Entity.CreatedAt, Entity.UpdatedAt, Entity.DomainEvents, Entity.EmitDomainEvent\(IDomainEvent\), object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.MemberwiseClone\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)

Properties

Color

The color of the User

[Required] public long Color { get; set; }

Property Value

long

Email

The email address of the User.

[Required] [EmailAddress] [StringLength(100)] public string Email { get; set; }

Property Value

string

Firstname

The unique username of the User.

[Required] [StringLength(50)] public string Firstname { get; set; }

Property Value

string

Lastname

The unique username of the User.

[Required] [StringLength(50)] public string Lastname { get; set; }

Property Value

string

PasswordHash

The hashed password of the User.

[Required] [StringLength(200)] public string PasswordHash { get; set; }

Property Value

string

PasswordResetToken

The password reset token for the User.

public string? PasswordResetToken { get; }

Property Value

string?

PasswordResetTokenExpiryDate

The time when the password reset token was issued.

public DateTimeOffset? PasswordResetTokenExpiryDate { get; set; }

Property Value

DateTimeOffset?

RestaurantId

The restaurant id that the Identity.Domain.Aggregates.UserAggregate.User owner or staff affiliated with.

public Guid? RestaurantId { get; set; }

Property Value

Guid?

Role

The role of the User.

[Required] public Role Role { get; set; }

Property Value

Role

RoleId

The id of the user role.

[ForeignKey("RoleId")] [Required] public Guid RoleId { get; set; }

Property Value

Guid

SortingIndex

Position of the Identity.Domain.Aggregates.UserAggregate.User in the view.

[Required] public int SortingIndex { get; set; }

Property Value

int

Username

The unique username of the User.

[Required] [StringLength(50)] public string Username { get; set; }

Property Value

string

Methods

ChangePassword\(string\)

Method that change the password of the User.

public void ChangePassword(string hashedPassword)

Parameters

hashedPassword string

New hashed password.

ClearResetToken\(\)

Wipe reset token after use.

public void ClearResetToken()

GeneratePasswordResetToken\(int, int\)

Method that generates a password reset token and assigns it to the user.

public void GeneratePasswordResetToken(int tokenLength = 128, int expiryTimeInMinutes = 15)

Parameters

tokenLength int

Length of the reset token.

expiryTimeInMinutes int

Token expiration time in minutes.

IsEmployee\(\)

Whether the user is an restaurant employee.

public bool IsEmployee()

Returns

bool

IsPasswordResetTokenValid\(string\)

Method that verify token validity.

public bool IsPasswordResetTokenValid(string token)

Parameters

token string

The token to verify.

Returns

bool

Boolean that signify validity.

UpdateBasicInformation\(string, string, string, string, long\)

Update basic information of the Identity.Domain.Aggregates.UserAggregate.User.

public void UpdateBasicInformation(string username, string firstname, string lastname, string email, long color)

Parameters

username string

Identity.Domain.Aggregates.UserAggregate.User.Username of the Identity.Domain.Aggregates.UserAggregate.User.

firstname string

Identity.Domain.Aggregates.UserAggregate.User.Firstname of the Identity.Domain.Aggregates.UserAggregate.User.

lastname string

Identity.Domain.Aggregates.UserAggregate.User.Lastname of the Identity.Domain.Aggregates.UserAggregate.User.

email string

Identity.Domain.Aggregates.UserAggregate.User.Email of the Identity.Domain.Aggregates.UserAggregate.User.

color long

Identity.Domain.Aggregates.UserAggregate.User.Color of the Identity.Domain.Aggregates.UserAggregate.User.

UpdateSortingIndex\(int\)

Update the position of the Identity.Domain.Aggregates.UserAggregate.User in the view.

public void UpdateSortingIndex(int newSortingIndex)

Parameters

newSortingIndex int

New position.

Last modified: 21 May 2024