Example #1
0
        public bool LoginUser(LoginUserEntity data)
        {
            var    C       = VM_OktaUrlAndKey.GetOktaUrlAndKey();
            string str     = C.Item1.Replace("users", "authn"); // to replace the specific text with blank
            var    client  = new RestClient(str);
            var    request = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/json");
            request.AddHeader("accept", "application/json");
            string oktaLogin = "******"username\": \"" + data.Username + "\",\n  \"password\": \"" + data.Password + "\",\n  \"options\": {\n    \"multiOptionalFactorEnroll\": true,\n    \"warnBeforePasswordExpired\": true\n  } \n}";

            request.AddParameter("application/json", oktaLogin, ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            if (response.StatusDescription == "Unauthorized")
            {
                return(false);
            }
            else
            {
                return(true);
            }
            //return true;
        }
Example #2
0
        public ApiResponse <LoginUserEntity> GetUserDetailByEmail(LoginUserEntity model)
        {
            var response = new ApiResponse <LoginUserEntity>();

            try
            {
                SqlParameter[] param = { new SqlParameter("Email", (object)model.Email ?? (object)DBNull.Value)
                                         ,                         new SqlParameter("CompanyNo", (object)model.CompanyNo ?? (object)DBNull.Value) };

                var result = _repository.ExecuteSQL <LoginUserEntity>("GetUserDetailByEmail", param).ToList();
                if (result == null)
                {
                    result = new List <LoginUserEntity>();
                }

                response.Success = true;
                response.Data    = result;
            }
            catch (Exception ex)
            {
                response.Message.Add(ex.Message);
            }

            return(response);
        }
Example #3
0
 public ActionResult RequestToAdmin(LoginUserEntity model)
 {
     try
     {
         var Result = loginApi.GetUserDetailByEmail(model);
         if (Result.Data != null && Result.Data.Count > 0)
         {
             var MailTo = model.Email;
             //RequestToAdmin Mail Template Remaining
             string bodyTemplate = System.IO.File.ReadAllText(Server.MapPath("~/MailTemplate/ForgetPassword.html"));
             bodyTemplate = bodyTemplate.Replace("##Email##", Result.Data[0].Email);
             bodyTemplate = bodyTemplate.Replace("##UserName##", Result.Data[0].UserName);
             bodyTemplate = bodyTemplate.Replace("##Password##", Security.Decrypt(Result.Data[0].Password));
             //Email.Send(MailTo, bodyTemplate, "[Axiom]", "", "");
             return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             string msg = "Email not register with us.";
             return(Json(new { success = false, message = msg }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Example #4
0
        public ApiResponse <int> UpdateNewGereatedPassword(LoginUserEntity model)
        {
            var response = new ApiResponse <int>();

            try
            {
                SqlParameter[] param = { new SqlParameter("UserAccessId", (object)model.UserAccessId ?? (object)DBNull.Value)
                                         ,                                new SqlParameter("Password", (object)model.Password ?? (object)DBNull.Value) };

                var result = _repository.ExecuteSQL <int>("UpdateNewGereatedPassword", param).FirstOrDefault();
                if (result == 1)
                {
                    response.Success = true;
                }
                else
                {
                    response.Success = false;
                }
            }
            catch (Exception ex)
            {
                response.Message.Add(ex.Message);
            }

            return(response);
        }
Example #5
0
        public ActionResult ResetPassword(LoginUserEntity model)
        {
            string currentUrl = Request.Url.AbsoluteUri;
            var    response   = homeApiController.GetCompanyNoBySiteUrl(currentUrl);

            model.CompanyNo = response.Data[0];

            CompanyDetailForEmailEntity objCompany = CommonFunction.CompanyDetailForEmail(model.CompanyNo);

            var Result = loginApi.GetUserDetailByEmail(model);

            if (Result.Data != null && Result.Data.Count > 0)
            {
                LoginUserEntity modelResetPassword = new LoginUserEntity();
                modelResetPassword.UserAccessId = Result.Data[0].UserAccessId;
                modelResetPassword.Password     = Security.Encrypt(CreateRandomPassword(8));
                var ResetPassword = loginApi.UpdateNewGereatedPassword(modelResetPassword);
                if (ResetPassword.Success)
                {
                    var    MailTo       = model.Email;
                    string bodyTemplate = System.IO.File.ReadAllText(Server.MapPath("~/MailTemplate/GetPassword.html"));
                    bodyTemplate = bodyTemplate.Replace("{FirstName}", Result.Data[0].FirstName).Replace("{LastName}", Result.Data[0].LastName);
                    bodyTemplate = bodyTemplate.Replace("{UserName}", Result.Data[0].UserName);
                    bodyTemplate = bodyTemplate.Replace("{Email}", Result.Data[0].Email);
                    //bodyTemplate = bodyTemplate.Replace("{Link}", ConfigurationManager.AppSettings["ResetEmailLink"].ToString());
                    bodyTemplate = bodyTemplate.Replace("{Password}", Security.Decrypt(modelResetPassword.Password));
                    bodyTemplate = bodyTemplate.Replace("{LogoURL}", objCompany.Logopath);
                    bodyTemplate = bodyTemplate.Replace("{ThankYou}", objCompany.ThankYouMessage);
                    bodyTemplate = bodyTemplate.Replace("{CompanyName}", objCompany.CompName);
                    bodyTemplate = bodyTemplate.Replace("{Link}", objCompany.SiteURL);

                    Email.Send(objCompany.CompNo, MailTo, bodyTemplate, "Login Details", "", "");
                    model.Msg = "Password has send successfully in your mail.";
                    return(View("~/Views/Login/Index.cshtml", model));
                }
                else
                {
                    model.Msg = "Please Try Again!.";
                    return(View("ResetPassword", model));
                }
            }
            else
            {
                model.Msg = "Email not register with " + objCompany.CompName;
                return(View("ResetPassword", model));
            }
        }
Example #6
0
        public ActionResult ForgetPassword(LoginUserEntity model)
        {
            string currentUrl = Request.Url.AbsoluteUri;
            var    response   = homeApiController.GetCompanyNoBySiteUrl(currentUrl);

            model.CompanyNo = response.Data[0];

            try
            {
                CompanyDetailForEmailEntity objCompany = CommonFunction.CompanyDetailForEmail(model.CompanyNo);

                var Result = loginApi.GetUserDetailByEmail(model);
                if (Result.Data != null && Result.Data.Count > 0)
                {
                    var MailTo = model.Email;
                    //string imagepath = Logopath + "/assets/images/LogoSmall.png";
                    //string path = "<img src='" + imagepath + "' class='navbar-brand' href='javascript:' style='width:180px;float: left;margin-left: 20px;padding-bottom: 11px;padding-top: 10px;'>";
                    string bodyTemplate = System.IO.File.ReadAllText(Server.MapPath("~/MailTemplate/ForgetPassword.html"));
                    bodyTemplate = bodyTemplate.Replace("##Email##", Result.Data[0].Email);
                    bodyTemplate = bodyTemplate.Replace("##UserName##", Result.Data[0].UserName);
                    bodyTemplate = bodyTemplate.Replace("##Password##", Security.Decrypt(Result.Data[0].Password));
                    bodyTemplate = bodyTemplate.Replace("##LogoURL##", objCompany.Logopath);
                    bodyTemplate = bodyTemplate.Replace("##ThankYou##", objCompany.ThankYouMessage);
                    bodyTemplate = bodyTemplate.Replace("##CompanyName##", objCompany.CompName);
                    bodyTemplate = bodyTemplate.Replace("##Link##", objCompany.SiteURL);


                    Email.Send(objCompany.CompNo, MailTo, bodyTemplate, "Login Details", "", "");
                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    string msg = "Email not register with us.";
                    return(Json(new { success = false, message = msg }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Example #7
0
 // GET: Login
 public ActionResult Index()
 {
     GetCompanyNoBySiteUrl();
     if (ProjectSession.LoggedInUserDetail != null && !String.IsNullOrEmpty(ProjectSession.LoggedInUserDetail.UserId))
     {
         if (ProjectSession.LoggedInUserDetail.RoleName.Contains("Administrator") || ProjectSession.LoggedInUserDetail.RoleName.Contains("DocumentAdmin"))
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Dashboard", "Home"));
         }
     }
     else
     {
         //var RequestUrl = Request.Url;
         LoginUserEntity model = new LoginUserEntity();
         return(View(model));
     }
 }
Example #8
0
        public ActionResult Index(LoginUserEntity model)
        {
            model.CompanyNo = ProjectSession.CompanyUserDetail.CompNo;
            var Result = loginApi.LoginUser(model);

            if (Result.Data != null && !String.IsNullOrEmpty(Result.Data[0].UserId))
            {
                ProjectSession.LoggedInUserDetail = new LoggedInUserDetail();
                ProjectSession.LoggedInUserDetail.UserAccessId = Result.Data[0].UserAccessId;
                ProjectSession.LoggedInUserDetail.Email        = Result.Data[0].Email.Trim();
                ProjectSession.LoggedInUserDetail.UserId       = Result.Data[0].UserId.Trim();
                ProjectSession.LoggedInUserDetail.UserName     = Result.Data[0].UserName.Trim();
                ProjectSession.LoggedInUserDetail.EmpId        = Result.Data[0].EmpId.Trim();
                ProjectSession.LoggedInUserDetail.IsAdmin      = Result.Data[0].IsAdmin;
                ProjectSession.LoggedInUserDetail.RoleName     = loginApi.GetUserType(Result.Data[0].UserId.Trim()).Data;

                if (!String.IsNullOrEmpty(Convert.ToString(TempData["ReturnUrl"])))
                {
                    if (Convert.ToString(TempData["ReturnUrl"]) != Common.CommonHelper.SiteRootPathUrl + "/")
                    {
                        return(Redirect(Convert.ToString(TempData["ReturnUrl"])));
                    }
                }
                if (ProjectSession.LoggedInUserDetail.RoleName.Contains("Administrator") || ProjectSession.LoggedInUserDetail.RoleName.Contains("DocumentAdmin"))
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else if (ProjectSession.LoggedInUserDetail.RoleName.Contains("Attorney"))
                {
                    return(RedirectToAction("Dashboard", "Home"));
                }
            }
            else
            {
                model.InvalidLogin = Result.Data[0].InvalidLogin;
            }

            return(View(model));
        }
 public bool LoginUser(LoginUserEntity item)
 {
     return(repository.LoginUser(item));
 }
Example #10
0
        public ActionResult ResetPassword()
        {
            LoginUserEntity model = new LoginUserEntity();

            return(View("~/Views/Login/ResetPassword.cshtml", model));
        }