예제 #1
0
        public LoginDetailCheck CheckLoginUserUsingOtp(LoginDetail objLoginDetails, string DeviceType)
        {
            LoginDetailCheck logincheck = new LoginDetailCheck();

            if (dbEntities.ETUsers.Any(x => x.Email.Trim().Equals(objLoginDetails.Email.Trim()) && x.Otp != null))
            {
                User = GetUserEmail(objLoginDetails.Email);
                if (CheckOtpIsValid(objLoginDetails.Email, objLoginDetails.Password))
                {
                    logincheck.loginDetails = GetUserEmail(objLoginDetails.Email);
                    logincheck.isSuccess    = true;
                    //logincheck.errorMessage = "";
                    if (logincheck.loginDetails.OtpReceivedDevice != DeviceType)
                    {
                        logincheck.errorMessage = "Device";
                    }
                    else if (!(logincheck.loginDetails.OtpReceivedDate > DateTime.Now))
                    {
                        logincheck.errorMessage = "Otp";
                    }
                    else
                    {
                        logincheck.errorMessage = "Valid";
                    }
                    return(logincheck);
                }
            }
            logincheck.isSuccess    = false;
            logincheck.errorMessage = objLoginDetails.GetTypes + " or Otp incorrect.";
            logincheck.loginDetails = null;
            return(logincheck);
        }
예제 #2
0
        public void LogForUserLogin(LoginDetailCheck checkLogin, string email)
        {
            ETUserLog loginCapture = new ETUserLog();

            loginCapture.IPAddress    = GetIPAddress();
            loginCapture.IsSuccess    = Convert.ToBoolean(checkLogin.isSuccess ? 1 : 0);
            loginCapture.LoginDate    = DateTime.Now;
            loginCapture.CreatedDate  = DateTime.Now;
            loginCapture.ModifiedDate = DateTime.Now;
            loginCapture.CreatedBy    = checkLogin.loginDetails.UserID.ToString();
            loginCapture.ModifiedBy   = checkLogin.loginDetails.UserID.ToString();
            if (checkLogin.loginDetails != null)
            {
                loginCapture.UserID    = checkLogin.loginDetails.UserID;
                loginCapture.LoginName = checkLogin.loginDetails.LoginName;
                loginCapture.Password  = Common.EncryptPassword(checkLogin.loginDetails.Password);
                loginCapture.SessionID = checkLogin.loginDetails.UserID;
            }
            else
            {
                loginCapture.UserID    = 0;
                loginCapture.LoginName = email;
                loginCapture.Password  = null;
                loginCapture.SessionID = 0;
            }
            dbEntities.ETUserLogs.Add(loginCapture);
            dbEntities.SaveChanges();
        }
예제 #3
0
        public LoginDetailCheck CheckLoginUser(LoginDetail objLoginDetails)
        {
            LoginDetailCheck logincheck = new LoginDetailCheck();

            if (dbEntities.ETUsers.Any(x => x.Email.Trim().Equals(objLoginDetails.Email.Trim()) && x.Password != null))
            {
                User = GetUserEmail(objLoginDetails.Email);
                if (CheckPasswordIsValid(objLoginDetails.Email, objLoginDetails.Password))
                {
                    logincheck.loginDetails = GetUserEmail(objLoginDetails.Email);
                    logincheck.isSuccess    = true;
                    logincheck.errorMessage = "";
                    return(logincheck);
                    //if (CheckIPAddress(objLoginDetails.Email, User.IsActive)) // Needs to change the ip address check
                    //{
                    //    logincheck.isSuccess = true;
                    //    logincheck.errorMessage = "";
                    //    logincheck.loginDetails = GetUserEmail(objLoginDetails.Email);
                    //    return logincheck;
                    //}
                    //else
                    //{
                    //    logincheck.isSuccess = false;
                    //    string currentipaddress = repcommon.GetIPAddress();
                    //    logincheck.errorMessage = "Permission denied. Cuurent IP:" + currentipaddress;
                    //    logincheck.loginDetails = null;
                    //    return logincheck;
                    //}
                }
            }
            logincheck.isSuccess    = false;
            logincheck.errorMessage = objLoginDetails.GetTypes + " or password incorrect.";
            logincheck.loginDetails = null;
            return(logincheck);
        }