Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        //public static bool EmailVerification(string EmailId, string UserName, string LoginName, string Otp, string Title)
        public static bool EmailVerification(string Title, ETUser UserDet, string VerifyMode)
        {
            try
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(hostAddress, portNumber);
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl             = sslId;
                smtp.Credentials           = new System.Net.NetworkCredential(smtpLogin, smtpPassword);

                System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
                mailMessage.From = new System.Net.Mail.MailAddress(fromMail, "Creative");
                mailMessage.To.Add(new System.Net.Mail.MailAddress(UserDet.Email));
                mailMessage.Subject    = Title;
                mailMessage.Priority   = System.Net.Mail.MailPriority.Normal;
                mailMessage.IsBodyHtml = true;

                string       message_Body = string.Empty;
                string       fPath        = Path.Combine(HttpRuntime.AppDomainAppPath, "Content/Emails/EmailVerification.html");
                string       logo         = frontUrl + "Content/Admin/Images/Logo.jpg";
                StreamReader reader       = new StreamReader(fPath);
                message_Body = reader.ReadToEnd();
                reader.Close();

                string DirectLogin = "******" + Common.EncryptPassword(UserDet.LoginName) + "&RandomValue=" + Common.EncryptPassword(UserDet.Otp) + "&VerifyMode=" + Common.EncryptPassword(VerifyMode) + "";
                message_Body = message_Body.Replace("@imgUrl@", logo);
                message_Body = message_Body.Replace("@UserName@", UserDet.FirstName + " " + UserDet.LastName);
                message_Body = message_Body.Replace("@LoginName@", UserDet.LoginName);
                message_Body = message_Body.Replace("@Otp@", UserDet.Otp);
                message_Body = message_Body.Replace("@SiteURL@", siteUrl);
                message_Body = message_Body.Replace("@year@", DateTime.Now.Year.ToString());
                message_Body = message_Body.Replace("@DirectLogin@", frontUrl + DirectLogin);
                message_Body = message_Body.Replace("@Details@", Title);
                message_Body = message_Body.Replace("@email@", UserDet.Email);

                mailMessage.Body = message_Body;

                Thread t1 = new Thread(delegate()
                {
                    smtp.Send(mailMessage);
                });

                t1.Start();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public ETUser GetUserForPasswordChange(long UserId)
        {
            User = new ETUser();
            User = dbEntities.ETUsers.Where(x => x.UserID == UserId).Single();

            //    .Select(item => new ETUser
            //{
            //    FirstName = item.FirstName,
            //    LastName = item.LastName,
            //    Email = item.Email,
            //    LoginName = item.LoginName,
            //    OldPassword = item.OldPassword,
            //    Password = item.Password,
            //    ConfirmPassword = item.ConfirmPassword,
            //    ModifiedBy = item.ModifiedBy,
            //    ModifiedDate = item.ModifiedDate,
            //}).ToList().Where(x => x.UserID == UserId).Single();
            return(User);
        }
Ejemplo n.º 5
0
        // Login

        #region GetUserEmail
        public ETUser GetUserEmail(string EmailId)
        {
            User = new ETUser();
            User = dbEntities.ETUsers.Where(x => x.Email == EmailId).SingleOrDefault();
            return(User);
        }
Ejemplo n.º 6
0
 public ETUser GetUser(long UserId)
 {
     User = new ETUser();
     User = dbEntities.ETUsers.Where(x => x.UserID == UserId).Single();
     return(User);
 }