public async Task <IAccessToken> GetTokenByPinCode(string pinCode, string cellular, string email)
        {
            PasswordBuilder pwd = new PasswordBuilder();

            IAccessToken accessToken = await m_session_repository.GetTokenByPinCode(pwd.MakeGuid(cellular, email, pinCode), pwd.MakePasswordHash(cellular, email, pinCode), pwd);

            if (accessToken == null)
            {
                return(default);
        public async Task <string> GeneratePinCode(IUserAccount user, string cellular, string email)
        {
            IAccessToken accessToken = await GenerateToken(user);

            PasswordBuilder  pb  = new PasswordBuilder();
            PinCodeGenerator gen = new PinCodeGenerator();

            string pinCode = gen.GenerateNextPinCode();

            await m_session_repository.ResetPinCode(accessToken.Guid, pb.MakeGuid(cellular, email, pinCode), pb.MakePasswordHash(cellular, email, pinCode));

            return(pinCode);
        }
        public async Task <bool> ResetPasspord(IAccessToken accessToken, string newPassword, string confirmPassword)
        {
            if (string.CompareOrdinal(newPassword, confirmPassword) == 0)
            {
                if (accessToken != null && !accessToken.HasExpired)
                {
                    PasswordBuilder pb = new PasswordBuilder();
                    await m_user_repository.ResetPassword(accessToken.User.Guid, pb.MakeGuid(accessToken.User.LoginName, newPassword), pb.MakePasswordHash(accessToken.User.LoginName, newPassword));

                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public override void Seed(EntityTypeBuilder <DataUserAccount> context)
        {
            PasswordBuilder pb = new PasswordBuilder();

            context.HasData(new DataUserAccount {
                IsAdmin = true, Name = "Admin", LoginName = "admin", Guid = Guid.NewGuid(), CreatedDateTime = DateTime.Now, PasswordGuid = pb.MakeGuid("admin", "1"), PasswordHash = pb.MakePasswordHash("admin", "1")
            });
        }