public async Task <IActionResult> Edit(int id, [Bind("Id,UserName,Password,Position")] LogInDetails logInDetails)
        {
            if (id != logInDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(logInDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LogInDetailsExists(logInDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(logInDetails));
        }
        public async Task <IActionResult> Create([Bind("Id,UserName,Password,Position")] LogInDetails logInDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(logInDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(logInDetails));
        }
        /// <summary>
        /// Func. for log in. do not use for testing login page..
        /// </summary>
        public void LogIn()
        {
            Map.GetElements();
            LogInDetails logInDetails  = new LogInDetails();
            var          inputEmail    = Map.inputUserName;
            var          inputPassword = Map.inputPassword;
            var          singInbutton  = Map.signInButton;

            inputEmail.SendKeys(logInDetails.username);
            inputPassword.SendKeys(logInDetails.password);
            singInbutton.Click();
        }
示例#4
0
        public ActionResult AgentLogin()
        {
            LogInDetails loginmodel = new LogInDetails();

            loginmodel.Errors = new List <string>();
            try
            {
                Session["newattach"]         = null;
                Session["UnId"]              = null;
                Session["ProfileId"]         = null;
                Session["Email"]             = null;
                Session["ApiKey"]            = null;
                Session["HprofileId"]        = null;
                Session["profileId"]         = null;
                Session["Home2"]             = null;
                Session["Policyinclustions"] = null;
                Session["EmailId"]           = null;
                Session["InsuredId"]         = null;
                Session["CustomerType"]      = null;
                Session["Actn"]              = null;
                Session["Policyinclustions"] = null;
                Session["UnitId"]            = null;
                Session["controller"]        = null;
                Session["Actname"]           = null;
                Session["Policylocal"]       = null;
                Session["InsuredName"]       = null;
                Session["MprofileId"]        = null;
                Session["hombud"]            = null;
                Session["PolicyNo"]          = null;
                Session["PrId"]              = null;
                Session["cid"] = null;
            }
            catch (Exception ex)
            {
            }
            return(View(loginmodel));
        }
示例#5
0
        // GET: api/LogInDetails/5
        public async Task <HttpResponseMessage> Post([FromBody] LogInDetails value)
        {
            try
            {
                string          UserName   = value.UserName;
                string          Password   = value.Password;
                LoginDetailsRef loginref   = new LoginDetailsRef();
                LogInDetails    loginmodel = new LogInDetails();
                List <string>   Errors     = new List <string>();
                loginref.ErrorMessage = new List <string>();
                var regexSpace = new Regex(@"\s");
                if (UserName == null || UserName == string.Empty || string.IsNullOrWhiteSpace(UserName.Trim()) || Password == null || Password == string.Empty || string.IsNullOrWhiteSpace(Password.Trim()))
                {
                    if (UserName == null || UserName == string.Empty || string.IsNullOrWhiteSpace(UserName.Trim()))
                    {
                        Errors.Add("UserName is required");
                    }
                    if (Password == null || Password == string.Empty || string.IsNullOrWhiteSpace(Password.Trim()))
                    {
                        Errors.Add("Password is required");
                    }
                }
                else
                {
                    string specialCharacters      = @"%!#$%^&*(-)?/><,:;'\|}]{[~`+=" + "\"";
                    char[] specialCharactersArray = specialCharacters.ToCharArray();
                    int    index = UserName.IndexOfAny(specialCharactersArray);
                    //index == -1 no special characters
                    if (index == -1)
                    {
                    }
                    else
                    {
                        Errors.Add("UserName allows only three special characters '_' '.' '@' ");
                    }
                    if (regexSpace.IsMatch(UserName.Trim()))
                    {
                        Errors.Add("UserName should not have space");
                    }
                    string justNumber  = new String(UserName.Trim().Where(Char.IsDigit).ToArray());
                    string justStrings = new String(UserName.Trim().Where(Char.IsLetter).ToArray());

                    if (justStrings == null || justStrings == string.Empty && UserName.Length <= 20)
                    {
                        Errors.Add("UserName does not allow only numeric values");
                    }
                }
                if (regexSpace.IsMatch(Convert.ToString(Password).Trim()))
                {
                    Errors.Add("Password should not have space");
                }

                if (Errors != null && Errors.Count() > 0)
                {
                    loginref.Status       = "Failure";
                    loginref.ErrorMessage = Errors;
                    return(Request.CreateResponse <LoginDetailsRef>(HttpStatusCode.BadRequest, loginref));
                }
                else
                {
                    if (await CommonUseFunctionClass.CheckUser(UserName, Password))
                    {
                        string str = CommonUseFunctionClass.GenerateToken(UserName, 20);
                        if (str != string.Empty || str != null || string.IsNullOrWhiteSpace(str.Trim()))
                        {
                            loginref.Status       = "Success";
                            loginref.Access_Token = str;
                            loginmodel.UserName   = UserName;
                            loginref.LogInData    = loginmodel;
                            return(Request.CreateResponse <LoginDetailsRef>(HttpStatusCode.OK, loginref));
                        }
                        else
                        {
                            loginref.Status = "Failure";
                            loginref.ErrorMessage.Add("Token Is Not generated");
                            return(Request.CreateResponse <LoginDetailsRef>(HttpStatusCode.BadRequest, loginref));
                        }
                    }
                    else
                    {
                        loginref.Status = "Failure";
                        loginref.ErrorMessage.Add("UserName or Password are not valid.");
                        return(Request.CreateResponse <LoginDetailsRef>(HttpStatusCode.BadRequest, loginref));
                    }
                }
            }
            catch (Exception xp)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, xp.Message));
            }
            return(null);
        }
示例#6
0
        public async System.Threading.Tasks.Task <ActionResult> AgentLogin(string UserName, string Password)
        {
            try
            {
                LoginDetailsRef loginref   = new LoginDetailsRef();
                LogInDetails    loginmodel = new LogInDetails();
                List <string>   Errors     = new List <string>();
                loginref.ErrorMessage = new List <string>();
                loginmodel.Errors     = new List <string>();
                var regexSpace = new Regex(@"\s");
                if (UserName == null || UserName == string.Empty || string.IsNullOrWhiteSpace(UserName.Trim()) || Password == null || Password == string.Empty || string.IsNullOrWhiteSpace(Password.Trim()))
                {
                    if (UserName == null || UserName == string.Empty || string.IsNullOrWhiteSpace(UserName.Trim()))
                    {
                        Errors.Add("User Name is required");
                    }
                    if (Password == null || Password == string.Empty || string.IsNullOrWhiteSpace(Password.Trim()))
                    {
                        Errors.Add("Password is required");
                    }
                }
                else
                {
                    string specialCharacters      = @"%!#$%^&*(-)?/><,:;'\|}]{[~`+=" + "\"";
                    char[] specialCharactersArray = specialCharacters.ToCharArray();
                    int    index = UserName.IndexOfAny(specialCharactersArray);
                    //index == -1 no special characters
                    if (index == -1)
                    {
                    }
                    else
                    {
                        Errors.Add("User Name allows only three special characters '_' '.' '@' ");
                    }
                    if (regexSpace.IsMatch(UserName.Trim()))
                    {
                        Errors.Add("User Name should not have space");
                    }
                    string justNumber  = new String(UserName.Trim().Where(Char.IsDigit).ToArray());
                    string justStrings = new String(UserName.Trim().Where(Char.IsLetter).ToArray());

                    if (justStrings == null || justStrings == string.Empty && UserName.Length <= 20)
                    {
                        Errors.Add("User Name does not allow only numeric values");
                    }
                }
                if (regexSpace.IsMatch(Convert.ToString(Password).Trim()))
                {
                    Errors.Add("Password should not have space");
                }

                if (Errors != null && Errors.Count() > 0)
                {
                    loginref.Status       = "Failure";
                    loginref.ErrorMessage = Errors;
                    return(View());
                }
                else
                {
                    //#region Remove
                    //LogInDetailsClass ld = new LogInDetailsClass();

                    //LoginDetailsRef LoginDetailsRef = new LoginDetailsRef();
                    //LoginDetailsRef.ErrorMessage = new List<string>();
                    //LoginDetailsRef = await ld.GetLogInDetailsPage(UserName, Password);
                    //{
                    //    if(LoginDetailsRef.ErrorMessage!=null && LoginDetailsRef.ErrorMessage.Count()>0)
                    //    {
                    //        loginmodel.Errors = LoginDetailsRef.ErrorMessage;
                    //        return View(loginmodel);
                    //    }
                    //}
                    //#endregion
                    if (await CommonUseFunctionClass.CheckUser(UserName, Password))
                    {
                        string str = CommonUseFunctionClass.GenerateToken(UserName, 20);
                        if (str != string.Empty || str != null || string.IsNullOrWhiteSpace(str.Trim()))
                        {
                            Session["IyId"]       = 9262;
                            loginref.Status       = "Success";
                            loginref.Access_Token = str;
                            loginmodel.UserName   = UserName;
                            loginref.LogInData    = loginmodel;
                            return(RedirectToAction("CustomerSearch", "Customer"));
                        }
                        else
                        {
                            loginref.Status = "Failure";
                            loginref.ErrorMessage.Add("Token is not generated");
                            ViewBag.ErrorMessage = "";
                            return(View());
                        }
                    }
                    else
                    {
                        loginref.Status = "Failure";
                        loginref.ErrorMessage.Add("User Name or Password are not valid.");
                        ViewBag.ErrorMessage = "User Name or Password are not valid.";
                        return(View());
                    }
                }
            }

            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "User Name or Password are not valid.";
                return(View());
            }

            return(View());
        }
        public async Task <LoginDetailsRef> GetLogInDetailsPage(string UserName, string Password)
        {
            string strEncrypt        = string.Empty;
            string strDecrypt        = string.Empty;
            string PlainTextEncrpted = string.Empty;
            string loginKey          = string.Empty;
            int    IyId           = 9262;
            string EncrptForLogin = String.Format("{0:ddddyyyyMMdd}", DateTime.UtcNow);

            // EncrptForLogin = "******";
            PlainTextEncrpted = IyId + "|" + UserName + "|InsureThatDirect";
            loginKey          = Encrypt(PlainTextEncrpted, EncrptForLogin);
            LoginDetailsRef    loginDetailsref   = new LoginDetailsRef();
            LogInDetails       logindetailsmodel = new LogInDetails();
            MasterDataEntities db = new MasterDataEntities();

            loginDetailsref.ErrorMessage = new List <string>();
            try
            {
                HttpClient hclient = new HttpClient();
                string     url     = System.Configuration.ConfigurationManager.AppSettings["APIURL"];
                hclient.BaseAddress = new Uri(url);
                hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                loginKey = loginKey.Replace("+", "%2B");
                loginDetailsref.ErrorMessage.Add("APISTARTED");
                HttpResponseMessage Res = await hclient.GetAsync("Login?loginKey=" + loginKey + ""); //change controller name and field name

                loginDetailsref.ErrorMessage.Add("APIExecuted");                                     //   LogInDetails loginmodel = new LogInDetails();
                if (Res.IsSuccessStatusCode)
                {
                    loginDetailsref.ErrorMessage.Add(Res.StatusCode.ToString());
                    //Storing the response details recieved from web api
                    var EmpResponse = Res.Content.ReadAsStringAsync().Result;
                    loginDetailsref.ErrorMessage.Add("Got Responce");
                    //Deserializing the response recieved from web api and storing into the Employee list // EncryptedPassword
                    logindetailsmodel = JsonConvert.DeserializeObject <LogInDetails>(EmpResponse);
                    loginDetailsref.ErrorMessage.Add("Deserialized");
                    //strEncrypt = Encrypt(Password, "TimsFirstEncryptionKey");//encrypt password method
                    // strDecrypt = Decrypt(strEncrypt, "TimsFirstEncryptionKey");//decrypt password method
                    strDecrypt = Decrypt(logindetailsmodel.EncryptedPassword, "TimsFirstEncryptionKey");
                    loginDetailsref.ErrorMessage.Add(strDecrypt);
                    if (logindetailsmodel.EncryptedPassword != null && strDecrypt == Password)
                    {
                        loginDetailsref.ErrorMessage.Add("Success");
                        loginDetailsref.Status     = "Success";
                        logindetailsmodel.UserName = UserName;
                        logindetailsmodel.Password = Password;
                        loginDetailsref.LogInData  = logindetailsmodel;
                        // Session["apiKey"] = logindetailsmodel.apiKey;
                        HttpContext.Current.Session["apiKey"]   = logindetailsmodel.apiKey;
                        HttpContext.Current.Session["UserName"] = logindetailsmodel.UserName;
                    }
                    else
                    {
                        loginDetailsref.Status = "Failure";
                        loginDetailsref.ErrorMessage.Add("Password is not valid.");
                    }
                }
            }
            catch (Exception xp)
            {
                loginDetailsref.ErrorMessage.Add("Catch");
                loginDetailsref.Status = "Failure";
                loginDetailsref.ErrorMessage.Add(xp.Message);
            }
            finally
            {
            }
            return(loginDetailsref);
        }