예제 #1
0
        public ActionResult Login(Models.UserLoginModel model, bool UserRemember = false, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (controller.Login(model.NickName, model.Password) && controller.ResultManager.IsCorrect)
            {
                if (controller.HasPasswordExpired)
                {
                    NotifyUser(messageError: "Su contraseña ha expirado, por favor defina una nueva contraseña");
                    return(RedirectToAction("ChangePassword"));
                }

                ///TODO: redirect to additional info if status is 'confirmed', or maybe better to put that validation at authorization or a site filter
                if (CurrentUser.StatusIdB == "tocomplete")
                {
                    NotifyUser("Favor de verificar/completar su información de perfil");
                    return(RedirectToAction("Edit"));
                }
                return(RedirectToLocal(returnUrl));
            }

            NotifyUser(resultManager: controller.ResultManager);
            return(View(model));
        }
예제 #2
0
 public ActionResult Index(Models.UserLoginModel objUserLogin)
 {
     if (objUserLogin.UserName == "admin" && objUserLogin.Password == "1234")
     {
         return(RedirectToAction("About"));
     }
     else
     {
         objUserLogin.Message = "Nombre de usuario/contraseña inválido";
         return(View(objUserLogin));
     }
 }
예제 #3
0
 public async Task <ActionResult> Login(Models.UserLoginModel userLoginModel)
 {
     if (ModelState.IsValid)
     {
         if (await UserManager.LoginAsync(userLoginModel.Name, userLoginModel.Password))
         {
             Session["username"] = userLoginModel.Name;
             return(RedirectToAction(nameof(Index)));
         }
         else
         {
             ModelState.AddModelError("", "登录失败");
         }
     }
     return(View(userLoginModel));
 }
예제 #4
0
        public ActionResult ForgotPassword(Models.UserLoginModel model, bool UserRemember = false, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (!controller.SetLoginToken(model.NickName) || !controller.ResultManager.IsCorrect)
            {
                NotifyUser(resultManager: controller.ResultManager);
                return(View(model));
            }

            NotifyUser(messageOk: "Se ha enviado un mensaje a su correo electrónico, en el encontrará una liga con la que podrá reiniciar su contraseña");

            return(RedirectToLocal(returnUrl));
        }
        public ActionResult Index(string responseId, string ReturnUrl)
        {
            string         version        = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            UserLoginModel UserLoginModel = new Models.UserLoginModel();

            ViewBag.Version = version;
            SetTermOfUse();
            if (ConfigurationManager.AppSettings["IsDemoMode"] != null)
            {
                Session["IsDemoMode"] = ConfigurationManager.AppSettings["IsDemoMode"].ToUpper();
            }
            else
            {
                Session["IsDemoMode"] = "null";
            }
            //   //get the responseId
            //    responseId = GetResponseId(ReturnUrl);
            //    //get the surveyId
            //     string SurveyId = _isurveyFacade.GetSurveyAnswerResponse(responseId).SurveyResponseList[0].SurveyId;
            //     //put surveyId in viewbag so can be retrieved in Login/Index.cshtml
            //     ViewBag.SurveyId = SurveyId;
            if (System.Configuration.ConfigurationManager.AppSettings["IsDemoMode"] != null)
            {
                var    IsDemoMode = System.Configuration.ConfigurationManager.AppSettings["IsDemoMode"];
                string UserId     = Epi.Web.Enter.Common.Security.Cryptography.Encrypt("1");
                if (!string.IsNullOrEmpty(IsDemoMode) && IsDemoMode.ToUpper() == "TRUE")
                {
                    FormsAuthentication.SetAuthCookie("*****@*****.**", false);

                    Session["UserId"]           = UserId;
                    Session["UserHighestRole"]  = 3;
                    Session["UserFirstName"]    = "John";
                    Session["UserLastName"]     = "Doe";
                    Session["UserEmailAddress"] = "*****@*****.**";
                    return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Home", new { surveyid = "" }));
                }
            }
            var configuration         = WebConfigurationManager.OpenWebConfiguration("/");
            var authenticationSection = (AuthenticationSection)configuration.GetSection("system.web/authentication");

            if (authenticationSection.Mode == AuthenticationMode.Forms)
            {
                return(View("Index", UserLoginModel));
            }
            else
            {
                try
                {
                    var CurrentUserName = System.Web.HttpContext.Current.User.Identity.Name;
                    var UserAD          = Utility.WindowsAuthentication.GetCurrentUserFromAd(CurrentUserName);
                    // validate user in EWE system
                    UserRequest User = new UserRequest();
                    User.IsAuthenticated   = true;
                    User.User.EmailAddress = UserAD.EmailAddress;

                    UserResponse result = _isurveyFacade.GetUserInfo(User);
                    if (result != null && result.User != null && result.User.Count() > 0)
                    {
                        FormsAuthentication.SetAuthCookie(CurrentUserName.Split('\\')[0].ToString(), false);
                        string UserId = Epi.Web.Enter.Common.Security.Cryptography.Encrypt(result.User[0].UserId.ToString());
                        Session["UserId"] = UserId;
                        //Session["UsertRole"] = result.User.Role;
                        Session["UserHighestRole"] = result.User[0].UserHighestRole;

                        Session["UserEmailAddress"] = result.User[0].EmailAddress;
                        Session["UserFirstName"]    = result.User[0].FirstName;
                        Session["UserLastName"]     = result.User[0].LastName;
                        Session["UGuid"]            = result.User[0].UGuid;
                        return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Home", new { surveyid = "" }));
                    }
                    else
                    {
                        //return View("Index", UserLoginModel);
                        ViewBag.ErrorName = "--You are not an authorized user of the system.--";
                        return(View("Error"));
                    }
                }
                catch (Exception ex)
                {
                    //ViewBag.ErrorName = ex.Message;
                    //return View("Error");
                    return(View("Index", UserLoginModel));
                }
            }
        }
        public ActionResult Index(string responseId, string ReturnUrl)
        {
            string         version        = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            UserLoginModel UserLoginModel = new Models.UserLoginModel();

            ViewBag.Version = version;

            var isDemoMode = AppSettings.GetBoolValue(AppSettings.Key.IsDemoMode);

            SetSessionValue(UserSession.Key.IsDemoMode, isDemoMode.ToString().ToUpper());

            if (isDemoMode)
            {
                int UserId = 1;
                FormsAuthentication.SetAuthCookie("*****@*****.**", false);

                // The EncryptedValue(true) attribute exists on UserSession.Key.UserId
                // therefore SetSessionValue will encrypt the UserId.
                SetSessionValue(UserSession.Key.UserId, UserId);

                SetSessionValue(UserSession.Key.UserHighestRole, 3);
                SetSessionValue(UserSession.Key.UserFirstName, "John");
                SetSessionValue(UserSession.Key.UserLastName, "Doe");
                SetSessionValue(UserSession.Key.UserEmailAddress, "*****@*****.**");
                return(RedirectToAction(ViewActions.Index, ControllerNames.Home, new { surveyid = "" }));
            }
            var configuration         = WebConfigurationManager.OpenWebConfiguration("/");
            var authenticationSection = (AuthenticationSection)configuration.GetSection("system.web/authentication");

            if (authenticationSection.Mode == AuthenticationMode.Forms)
            {
                _logger.Information("Using Forms Authentication Mode");
                return(View("Index", UserLoginModel));
            }
            else
            {
                _logger.Information("Using Active Directory Authentication Mode");
                var CurrentUserName = System.Web.HttpContext.Current.User.Identity.Name;
                try
                {
                    var UserAD = Utility.WindowsAuthentication.GetCurrentUserFromAd(CurrentUserName);
                    // validate user in EWE system
                    UserRequest User = new UserRequest();
                    User.IsAuthenticated   = true;
                    User.User.EmailAddress = UserAD.EmailAddress;

                    UserResponse result = _securityFacade.GetUserInfo(User);
                    if (result != null && result.User.Count() > 0)
                    {
                        FormsAuthentication.SetAuthCookie(CurrentUserName.Split('\\')[0].ToString(), false);
                        SetSessionValue(UserSession.Key.UserId, result.User[0].UserId);
                        //SetSessionValue(UserSession.Key.UsertRole, result.User.Role);
                        SetSessionValue(UserSession.Key.UserHighestRole, result.User[0].UserHighestRole);

                        SetSessionValue(UserSession.Key.UserEmailAddress, result.User[0].EmailAddress);
                        SetSessionValue(UserSession.Key.UserFirstName, result.User[0].FirstName);
                        SetSessionValue(UserSession.Key.UserLastName, result.User[0].LastName);
                        SetSessionValue(UserSession.Key.UGuid, result.User[0].UGuid);
                        return(RedirectToAction(ViewActions.Index, ControllerNames.Home, new { surveyid = "" }));
                    }
                    else
                    {
                        return(View("Index", UserLoginModel));
                    }
                }
                catch (Exception ex)
                {
                    return(View("Index", UserLoginModel));
                }
            }
        }
예제 #7
0
        private async void BtnLogIN_Click(object sender, EventArgs e)
        {
            try
            {
                Drawable icon_error = Resources.GetDrawable(Resource.Drawable.alert);
                icon_error.SetBounds(0, 0, 40, 30);
                if (txt_UserName.Text != "")
                {
                    if (txt_Password.Text != "")
                    {
                        UserLoginModel _objUserLoginModel = new Models.UserLoginModel();
                        StatusModel.LoginUserName   = txt_UserName.Text;
                        _objUserLoginModel.UserName = txt_UserName.Text;
                        _objUserLoginModel.Password = txt_Password.Text;

                        if (StatusModel.LoginUserStatus == 0)
                        {
                            WebHelpper _objHelper = new WebHelpper();

                            string Url = StatusModel.Url + "EmployeeLogIn";

                            progressDialog = ProgressDialog.Show(this, Android.Text.Html.FromHtml("<font color='#EC407A'> Please wait...</font>"), Android.Text.Html.FromHtml("<font color='#EC407A'> Checking User Info...</font>"), true);

                            var PostString  = JsonConvert.SerializeObject(_objUserLoginModel);
                            var requestTemp = await _objHelper.MakePostRequest(Url, PostString, true);

                            ResultModel ResultgetRequest = JsonConvert.DeserializeObject <ResultModel>(requestTemp);

                            if (ResultgetRequest.success == 1)
                            {
                                _MyFirebaseIIDService.OnTokenRefresh(txt_UserName.Text.Trim(), 0);
                                clear();
                                progressDialog.Hide();
                                Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show();
                                Intent intent = new Intent(this, typeof(CheckVendorRequestActivity));
                                this.StartActivity(intent);
                            }

                            else
                            {
                                progressDialog.Hide();
                                Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show();
                                clear();
                                return;
                            }
                        }
                        else if (StatusModel.LoginUserStatus == 1)
                        {
                            WebHelpper _objHelper = new WebHelpper();

                            string Url = StatusModel.Url + "VendorLogIn";

                            progressDialog = ProgressDialog.Show(this, Android.Text.Html.FromHtml("<font color='#EC407A'> Please wait...</font>"), Android.Text.Html.FromHtml("<font color='#EC407A'> Checking User Info...</font>"), true);

                            var PostString  = JsonConvert.SerializeObject(_objUserLoginModel);
                            var requestTemp = await _objHelper.MakePostRequest(Url, PostString, true);

                            ResultModel ResultgetRequest = JsonConvert.DeserializeObject <ResultModel>(requestTemp);

                            if (ResultgetRequest.success == 1)
                            {
                                _MyFirebaseIIDService.OnTokenRefresh(txt_UserName.Text.Trim(), 1);
                                clear();
                                progressDialog.Hide();
                                Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show();
                                Intent intent = new Intent(this, typeof(VendorCreateNewRequestActivity));
                                this.StartActivity(intent);
                            }

                            else
                            {
                                progressDialog.Hide();
                                Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show();
                                clear();
                                return;
                            }
                        }
                        // ADD Insert Code Here
                    }
                    else
                    {
                        txt_Password.RequestFocus();
                        txt_Password.SetError("Please Enter Password First", icon_error);
                    }
                }
                else
                {
                    txt_UserName.RequestFocus();
                    txt_UserName.SetError("Please Enter UserName First", icon_error);
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.ToString();
                Toast.MakeText(this, ErrorMsg, ToastLength.Long).Show();
            }
        }