Example #1
0
        public Credential Login(Credential credential)
        {
            ECredential eCredential = _iDCredential.Read <ECredential>(a => a.Username == credential.Username && a.IsActive == true);

            if (eCredential != null && BCrypt.Net.BCrypt.Verify(credential.Password + eCredential.Salt, eCredential.Password))
            {
                return(Credential(eCredential));
            }
            else
            {
                return(credential);
            }
        }
        public Credential ChangePassword(int updatedBy, Credential credential)
        {
            ECredential eCredential = _iDCredential.Read <ECredential>(a => a.Username == credential.Username && a.IsActive == true);

            if (eCredential != null && BCrypt.Net.BCrypt.Verify(credential.Password + eCredential.Salt, eCredential.Password))
            {
                eCredential.Salt     = BCrypt.Net.BCrypt.GenerateSalt();
                eCredential.Password = BCrypt.Net.BCrypt.HashPassword(credential.NewPassword + eCredential.Salt);
                eCredential          = _iDCredential.Update(eCredential);
                return(Credential(eCredential));
            }
            else
            {
                return(credential);
            }
        }
Example #3
0
        private Credential Credential(ECredential eCredential)
        {
            return(new Credential
            {
                IsActive = eCredential.IsActive,

                CreatedDate = eCredential.CreatedDate,
                UpdatedDate = eCredential.UpdatedDate,

                CreatedBy = eCredential.CreatedBy,
                UpdatedBy = eCredential.UpdatedBy,
                CredentialId = eCredential.CredentialId,

                Email = eCredential.Email,
                Username = eCredential.Username
            });
        }