コード例 #1
0
        public bool CheckIfLocked(LoginInfo login, PasswordPolicy passwordpolicy)
        {
            CredentialInfo usercredentialinfo = UserCredentailInfo(login);

            if (passwordpolicy.LockoutDuration.Value == null)
            {
                return(false);
            }
            if (usercredentialinfo.IsLocked)
            {
                //user was locked down now as time is over he is locked out
                if (DateTime.UtcNow > usercredentialinfo.LockedOn.AddMinutes(Convert.ToInt32(passwordpolicy.LockoutDuration.Value)))
                {
                    IManagerCredential managecredential = new ManagerCredential();
                    IManagerCredential crd              = new ManagerCredential();
                    ILayoutManager     layoutManager    = new LayoutManager();
                    IReviewCredential  ReviewCredential = new ReviewCredential();
                    Guid tenantId = layoutManager.GetTenantId(InfoType.Tenant, login.TenantCode);
                    var  userId   = crd.GetUserName(tenantId, login.UserName);
                    managecredential.UpdateLockedStatus(tenantId, usercredentialinfo.CredentialId, false, 0, null);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public bool LockUserAccount(LoginInfo login, PasswordPolicy passwordpolicy) //if incorect only
        {
            var isLocked                        = false;
            IManagerCredential crd              = new ManagerCredential();
            ILayoutManager     layoutManager    = new LayoutManager();
            IReviewCredential  ReviewCredential = new ReviewCredential();
            Guid tenantId                       = layoutManager.GetTenantId(InfoType.Tenant, login.TenantCode);

            CredentialInfo usercredentialinfo = UserCredentailInfo(login);

            if (passwordpolicy.LockoutAttempt.Value != null)
            {
                int?userpermissablelockoutAttemptcount = 1;
                if (usercredentialinfo.InvalidAttemptCount == null || usercredentialinfo.InvalidAttemptCount == 0)
                {
                    usercredentialinfo.InvalidAttemptCount = 1;
                }
                userpermissablelockoutAttemptcount = Convert.ToInt32(passwordpolicy.LockoutAttempt.Value);
                if (usercredentialinfo.InvalidAttemptCount >= userpermissablelockoutAttemptcount)
                {//lock the user
                    IManagerCredential managecredential = new ManagerCredential();
                    managecredential.UpdateLockedStatus(tenantId, usercredentialinfo.CredentialId, true, usercredentialinfo.InvalidAttemptCount, DateTime.UtcNow);
                    isLocked = true;
                }
                else //invalid attempt count increses
                {
                    IManagerCredential managecredential = new ManagerCredential();
                    managecredential.UpdateLockedStatus(tenantId, usercredentialinfo.CredentialId, false, usercredentialinfo.InvalidAttemptCount + 1, null);
                }
            }
            return(isLocked);
        }
コード例 #3
0
        // public bool checkAccess(LoginInfo login)
        // {
        //     IManagerCredential crd = new ManagerCredential();
        //     ILayoutManager layoutManager = new LayoutManager();
        //     IManagerRole roleManager = new ManagerRole();

        //     if (string.IsNullOrEmpty(login.TenantCode) || string.IsNullOrEmpty(login.UserName))
        //     return false;
        //     //Get tenant id with code
        //     Guid tenantId = layoutManager.GetTenantId(InfoType.Tenant, login.TenantCode);
        //     if (tenantId == Guid.Empty)
        //     return false;
        //     //Validate UserName
        //     var userId = crd.GetUserName(tenantId, login.UserName);
        //     if (userId == Guid.Empty)
        //     return false;
        //     // var userDetails = roleManager.GetUserDetails(tenantId, userId);
        //     // if (userDetails.Id == Guid.Empty)
        //     // return false;
        //     var credentialData=crd.GetCredential(tenantId,userId);
        //     return credentialData.IsNew;
        // }

        public List <CredentialHistory> GetCredentialHistory(string tenentCode, string username, int count)
        {
            IManagerCredential crd              = new ManagerCredential();
            ILayoutManager     layoutManager    = new LayoutManager();
            IReviewCredential  ReviewCredential = new ReviewCredential();
            Guid tenantId = layoutManager.GetTenantId(InfoType.Tenant, tenentCode);
            Guid userId   = crd.GetUserName(tenantId, username);
            List <CredentialHistory> result = ReviewCredential.GetCredentialHistory(tenantId, userId, count);

            return(result);
        }