using UnivateProperties_API.Helpers;

namespace UnivateProperties_API.Model.Users
{
    public class User : BaseEntity
    {
        #region Constructor
        public User(string username, string password)
        {
            Username = username;

            MyCommon.CreatePasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt);

            PasswordHash = passwordHash;
            PasswordSalt = passwordSalt;
        }

        /// <summary>
        /// Do not use when creating new user
        /// </summary>
        public User()
        {

        }
        #endregion Constructor

        #region Properties
        public string Username { get; set; }
        public string Role { get; set; }
        public byte[] PasswordHash { get; set; }
        public byte[] PasswordSalt { get; set; }
        public bool Verified { get; set; }
        public string Token { get; set; }
        #endregion Properties

        #region Methods
        public bool IsUserInRole(string role)
        {
            return Role == role;
        }
        #endregion
    }
}