public ActionResult Register(string userName, string email, string password, string confirmPassword, string roleName)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword, roleName))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    // assign user to role
                    this.RoleService.AddUserToRole(userName, roleName);

                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
Beispiel #2
0
        public ActionResult Register(string userName, string email, string password, string confirmPassword)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                Usuario usuario = new Usuario();
                usuario.UserIdMembership = (System.Guid)Membership.GetUser(userName).ProviderUserKey;
                usuario.Nome             = "NOme ";
                usuarioRepositorio.Add(usuario);
                usuarioRepositorio.Save();
                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
Beispiel #3
0
        public ActionResult Register(string userName, string email, string password, string confirmPassword)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    ControllerContext.HttpContext.User = new MemberShipPrincipal(userName);
                    this.Update("logindisplay", "Home.LoginInfo");
                    new HomeController().RenderHome();
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                    this.Update("content");
                }
            }

            return(this.Render());
        }
        public ActionResult Register(string imie, string nazwisko, string nip, string tel, string userName, string email, string password, string confirmPassword,
                                     string city, string citycode, string street, string streetNo)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            Response.AppendHeader("X-XSS-Protection", "0");

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    //ustawienie go jako klienta
                    Roles.AddUserToRole(userName, "Klient");

                    string hash = BitConverter.ToString(SHA1Managed.Create().ComputeHash(Encoding.Default.GetBytes(password))).Replace("-", "");
                    Debug.WriteLine("Długość wynosi: " + hash.Length);

                    //tworzenie nowego klienta
                    Klinet kl = new Klinet();
                    kl.Imie            = imie;
                    kl.Nazwisko        = nazwisko;
                    kl.E_Mail          = email;
                    kl.NIP             = nip;
                    kl.Telefon         = tel;
                    kl.Login           = userName;
                    kl.Haslo           = hash;
                    kl.Rola_w_systemie = "kl";
                    db.AddToKlinet(kl);
                    db.SaveChanges();

                    var nrk = (from p in db.Klinet
                               where p.NIP == nip
                               select p.NrKlienta
                               ).First();

                    //tworzenie adresu
                    Adres ad = new Adres();
                    ad.Kod       = citycode;
                    ad.Miasto    = city;
                    ad.NrDomu    = streetNo;
                    ad.Ulica     = street;
                    ad.NrKlienta = nrk;
                    db.AddToAdres(ad);
                    db.SaveChanges();


                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
Beispiel #5
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (ValidateLogOn(model.UserName, model.Password))
                {
                    // Make sure we have the username with the right capitalization
                    // since we do case sensitive checks for OpenID Claimed Identifiers later.
                    string userName = MembershipService.GetCanonicalUsername(model.UserName);

                    FormsAuth.SignIn(userName, model.RememberMe);

                    // Make sure we only follow relative returnUrl parameters to protect against having an open redirector
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Resources.UsernamePasswordIncorrect);
                }
            }
            return(View(model));
        }
Beispiel #6
0
        public ActionResult Register(
            string userName, string email,
            string password, string confirmPassword,
            string firstName, string lastName)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);
                RoleService.AddUserToRole(userName, "Public");
                if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService)))
                {
                    ((AccountMembershipService)MembershipService).SetUserAdditionalData(userName,
                                                                                        new TableStorageMembershipProvider.AdditionalUserData(firstName, lastName));
                }

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return(RedirectToAction("About", "Home"));
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName.Trim(), password.Trim()))
            {
                return(View());
            }

            //var validate = Models.Users.UserAut(userName, password);

            FormsAuth.SignIn(userName, rememberMe);

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                ///save log history
                ///update localuser table
                //var Id = Models.Util.UserAut(userName, password).Email;

                Models.Util.SaveLogIn(userName.Trim());
                Models.Util.updateLogUser(userName.Trim());
                Session.Add("user", userName.Trim());
                Session.Add("pass", password.Trim());
                return(RedirectToAction("DefaultMenu", "Home"));
            }
        }
Beispiel #8
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);
            if (MembershipService.GetType().IsAssignableFrom(typeof(AccountMembershipService)))
            {
                var userData =
                    ((AccountMembershipService)MembershipService).GetUserAdditionalData(userName);
            }


            if (RoleService.IsUserInRole(userName, "Administrator"))
            {
                Session["UserRole"] = "Administrator";
            }

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("About", "Home"));
            }
        }
        public object LoginHandler(JObject request)
        {
            var UserCode = request.Value <string>("usercode");
            var Password = request.Value <string>("password");

            //用户名密码检查
            if (String.IsNullOrEmpty(UserCode) || String.IsNullOrEmpty(Password))
            {
                return new { status = "error", message = "用户名或密码不能为空!" }
            }
            ;

            //用户名密码验证
            if (UserCode != Password)
            {
                return new { status = "error", message = "用户名或密码不正确!" }
            }
            ;

            //取得用户登陆信息
            var Loginer = new LoginerBase()
            {
                UserCode = UserCode, UserName = UserCode.ToUpper()
            };

            //调用框架中的登陆机制
            var effectiveHours = ConfigHelper.GetConfigInt("LoginEffectiveHours", 8);

            FormsAuth.SignIn(Loginer, 60 * effectiveHours);

            //返回登陆成功
            return(new { status = "success", message = "登陆成功!" });
        }
Beispiel #10
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (ValidateLogOn(model.UserName, model.Password))
                {
                    // Make sure we have the username with the right capitalization
                    // since we do case sensitive checks for OpenID Claimed Identifiers later.
                    string userName = MembershipService.GetCanonicalUsername(model.UserName);

                    FormsAuth.SignIn(userName, model.RememberMe);

                    //Jamie
                    AdProvider adProvider = new AdProvider();
                    String     catagory   = adProvider.GetCatagory(userName);
                    Session["adUri"] = "/Content/images/" + catagory + ".png";

                    // Make sure we only follow relative returnUrl parameters to protect against having an open redirector
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }
            return(View(model));
        }
Beispiel #11
0
        // POST: /Login/
        public JsonResult Login(JObject data)
        {
            string UserCode = data.Value <string>("user_code");
            string Password = data.Value <string>("password");
            string IP       = data.Value <string>("ip");
            string City     = data.Value <string>("city");

            data["user_code"] = UserCode;
            data["password"]  = Md5Util.MD5(Password);
            data["LoginIP"]   = IP;
            data["LoginCity"] = City;

            AppConnectionString = ConfigurationManager.ConnectionStrings["app"].ConnectionString;
            DataSet dt = base.RunProcedureDataSet(data, "vdp_sys_Login", "app");
            //if (dt.Rows.Count > 0)
            var ResultID  = dt.Tables[0].Rows[0]["result_id"];
            var ResultMsg = (string)dt.Tables[0].Rows[0]["result_msg"];

            //var loginResult = Base_UserService.Instance.Login(UserCode, Md5Util.MD5(Password), IP, City);
            if (ResultID.ToString() == "0")
            {
                Base_User b = new Base_User();
                b.city         = "";// (string)dt.Rows[0]["city"];
                b.RealName     = (string)dt.Tables[1].Rows[0]["real_name"];
                b.DepartmentID = (int)dt.Tables[1].Rows[0]["department_id"];
                b.UserId       = (int)dt.Tables[1].Rows[0]["id"];
                b.UserCode     = (String)dt.Tables[1].Rows[0]["user_code"];

                b.RoleIDs        = (string)dt.Tables[1].Rows[0]["role_ids"];
                b.DepartmentCode = ((int)dt.Tables[1].Rows[0]["department_id"]).ToString();
                var loginer = new BaseLoginer
                {
                    UserId   = (int)dt.Tables[1].Rows[0]["id"],           //. user.UserId,
                    UserCode = (string)dt.Tables[1].Rows[0]["user_code"], // user.UserCode,
                    //  Password = (string)dt.Tables[1].Rows[0]["Password"],// user.Password,
                    UserName = (string)dt.Tables[1].Rows[0]["real_name"], // user.RealName,
                    RoleIDs  = (string)dt.Tables[1].Rows[0]["role_ids"],
                    //  DepartmentCode =((int)dt.Tables[1].Rows[0]["DepartmentID"]).ToString(),
                    Data    = b,
                    IsAdmin = false
                };


                Session["logininfo"] = "";


                //set timeout
                var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours"));


                //执行web登录
                FormsAuth.SignIn(loginer.UserId.ToString(), loginer, effectiveHours);
            }
            else
            {
                LogHelper.Write("Login Failed!Account:" + UserCode + ",password:" + Password + "。reason:" + ResultMsg);
            }
            return(Json(new { s = ResultID, message = ResultMsg }, JsonRequestBehavior.DenyGet));
        }
Beispiel #12
0
        public ActionResult Index()
        {
            ViewBag.CnName = "STD MiniMES系统";
            ViewBag.EnName = "STD MiniMES System";

            var Token = Request["Token"];

            if (!string.IsNullOrEmpty(Token))
            {
                string APIGatewayUrl = ZConfig.GetConfigString("APIGatewayUrl");
                var    data          = new
                {
                    AppCode = "EPS",
                    ApiCode = "PostValidateToken",
                    Token   = Token
                };

                var result = HttpHelper.PostWebApi(APIGatewayUrl, JsonConvert.SerializeObject(data), 18000);
                if (result != null)
                {
                    if (result.status == true)
                    {
                        var UserInfo = result.UserInfo;

                        //调用框架中的登录机制
                        var loginer = new LoginerBase
                        {
                            UserId   = UserInfo.UserId,
                            UserType = "2",
                            TenantId = UserInfo.TenantId,
                            UserCode = UserInfo.UserCode,
                            UserName = UserInfo.UserName,
                            ShiftId  = UserInfo.ShiftId
                        };

                        var effectiveHours = ZConfig.GetConfigInt("LoginEffectiveHours");
                        FormsAuth.SignIn(loginer.UserCode, loginer, 60 * effectiveHours);

                        ZCache.SetCache("MenuData", result.MenuData);

                        return(Redirect("Home"));
                    }
                }

                //return View("授权Token验证失败!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。");
                return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login"));
            }
            else
            {
                //return View("授权参数错误!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。");
                //return View();
                return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login"));
            }
        }
Beispiel #13
0
        public JsonResult Login(JObject data)
        {
            string   UserCode = data.Value <string>("username");
            string   Password = data.Value <string>("password");
            string   IP       = data.Value <string>("ip");
            string   City     = data.Value <string>("city");
            Sys_User user     = new Sys_User()
            {
                Code     = UserCode,
                Password = MD5Encrypt.Encrypt(Password, 64)
            };

            ISys_UserService bLL = DIFactory.GetService <ISys_UserService>();
            var loginResult      = bLL.Login(user);

            if (loginResult.Succeed && loginResult.ResultData != null)
            {
                //登录成功后,查询当前用户数据
                user = loginResult.ResultData as Sys_User;

                //调用框架中的登录机制
                var loginer = new BaseLoginer
                {
                    UserId   = 0,// user.UserId,
                    ID       = user.Id,
                    UserCode = user.Code,
                    Password = user.Password,
                    UserName = user.Name,
                    Data     = user,
                    IsAdmin  = user.Explain == "管理员用户" //根据用户Explain判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他
                };

                //读取配置登录默认失效时长:小时
                var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours"));


                //执行web登录
                FormsAuth.SignIn(loginer.ID.ToString(), loginer, effectiveHours);
                log.Info("登录成功!用户:" + loginer.UserName + ",账号:" + loginer.UserCode + ",密码:---");
                //设置服务基类中,当前登录用户信息
                // this.CurrentBaseLoginer = loginer;
                //登陆后处理
                //更新用户登陆次数及时间(存储过程登录,数据库已经处理)
                //添加登录日志
                string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}",
                                                loginer.UserName, loginer.UserCode, loginer.UserCode, "---" /*loginer.Password*/);
                //更新其它业务
            }
            else
            {
                log.Info("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + loginResult.ResultMsg);
            }
            return(Json(loginResult, JsonRequestBehavior.DenyGet));
        }
Beispiel #14
0
        /// <summary>
        /// Controller implementation
        /// </summary>
        /// <param name="context">The context.</param>
        public override void DoProcessRequest(IExecutionContext context)
        {
            if (!ValidateLogon())
            {
                return;
            }

            context.Authenticate(FormsAuth.SignIn(username, rememberMe));

            context.Transfer("/home/index");
        }
Beispiel #15
0
        // POST: /Login/
        public JsonResult Login(JObject data)
        {
            string UserCode    = data.Value <string>("usercode");
            string Password    = data.Value <string>("pwd");
            string IP          = data.Value <string>("ip");
            string City        = data.Value <string>("city");
            var    loginResult = Base_UserService.Instance.Login(UserCode, Md5Util.MD5(Password), IP, City);

            if (loginResult.Succeed)
            {
                //登录成功后,查询当前用户数据
                var user = Base_UserService.Instance.GetEntity(ParamQuery.Instance()
                                                               .AndWhere("UserCode", UserCode).AndWhere("Password", Md5Util.MD5(Password))
                                                               .AndWhere("Enabled", 1).AndWhere("IsAudit", 1));

                //调用框架中的登录机制
                var loginer = new BaseLoginer
                {
                    UserId   = user.UserId,
                    UserCode = user.UserCode,
                    Password = user.Password,
                    UserName = user.RealName,
                    Data     = user,
                    IsAdmin  = user.UserType == 1 //根据用户UserType判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他
                };

                //读取配置登录默认失效时长:小时
                var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours"));
                // 无限光年网络科技

                //执行web登录
                FormsAuth.SignIn(loginer.UserId.ToString(), loginer, effectiveHours);
                LogHelper.Write("登录成功!用户:" + loginer.UserName + ",账号:" + UserCode + ",密码:" + Password);
                //设置服务基类中,当前登录用户信息
                //this.CurrentBaseLoginer = loginer;
                //登陆后处理
                //更新用户登陆次数及时间(存储过程登录,数据库已经处理)
                //添加登录日志
                string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}",
                                                loginer.UserName, loginer.UserId, loginer.UserCode, loginer.Password);
                Base_SysLogService.Instance.AddLoginLog(userinfo, IP, City);
                //更新其它业务
            }
            else
            {
                LogHelper.Write("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + loginResult.ResultMsg);
            }
            return(Json(loginResult, JsonRequestBehavior.DenyGet));
        }
Beispiel #16
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (ValidateLogOn(userName, password))
            {
                FormsAuth.SignIn(userName, rememberMe);
                ControllerContext.HttpContext.User = new MemberShipPrincipal(userName);

                this.Update("logindisplay", "Home.LoginInfo");
                if (String.IsNullOrEmpty(returnUrl))
                {
                    new HomeController().RenderHome();
                }
            }
            return(this.Render());
        }
Beispiel #17
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #18
0
        public ActionResult Initialize()
        {
            string[] roles = RoleService.GetAllRoles();

            if (roles.Length == 0)
            {
                RoleService.CreateRole("Public");
                RoleService.CreateRole("Agency");
                RoleService.CreateRole("Administrator");

                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser("admin", "12345", "*****@*****.**");
                RoleService.AddUserToRole("admin", "Administrator");
                FormsAuth.SignIn("admin", false /* createPersistentCookie */);
            }
            return(RedirectToAction("About", "Home"));
        }
Beispiel #19
0
        public ActionResult LogOn(string userName, string password, bool isExpire)
        {
            var response = AsyncGetContent("api/system/employee/" + userName + "/" + password).ReadAsAsync <ResponseModel>().Result;

            if (response.IsSuccess)
            {
                var loginEmployee  = JsonConvert.DeserializeObject <EmployeeDataObject>(response.Result.ToString());
                var effectiveHours = int.Parse(ConfigurationManager.AppSettings["LoginEffectiveHours"]);
                FormsAuth.SignIn(loginEmployee.RealName, loginEmployee, isExpire == true ? 60 * effectiveHours : 0);
                //登陆后处理
                return(Json(new { IsSuccess = true, StatusCode = 200, Result = "登陆成功!" }));
            }
            else
            {
                return(Json(new { IsSuccess = false, StatusCode = 200, Result = response.Result }));
            }
        }
Beispiel #20
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            string strName = string.Empty;

            if (Request.Cookies.AllKeys.Contains("User"))
            {
                strName = Request.Cookies.Get("User").Value;
            }

            ViewData["User"] = strName;

            if (!ValidateLogOn(userName.Trim(), password.Trim()))
            {
                return(View());
            }

            //var validate = Models.Users.UserAut(userName, password);

            FormsAuth.SignIn(userName, rememberMe);

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                ///save log history
                ///update localuser table
                //var Id = Models.Util.UserAut(userName, password).Email;

                Models.Util.SaveLogIn(userName.Trim());
                Models.Util.updateLogUser(userName.Trim());
                Session.Add("user", userName.Trim());
                Session.Add("pass", password.Trim());

                if (rememberMe)
                {
                    HttpCookie cookie = new HttpCookie("User");
                    cookie.Expires = DateTime.Now.AddYears(1);
                    cookie.Value   = userName.Trim();
                    Response.Cookies.Add(cookie);
                }
                return(RedirectToAction("Index", "Dashboard"));
            }
        }
Beispiel #21
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);


            var cook = HttpContext.Request.Cookies.Get(User.Identity.Name + "myCookieCart");

            //czyszczenie ciastka
            var newCookie = new HttpCookie(userName + "myCookieCart", ".");

            newCookie.Expires = DateTime.Now.AddDays(1);
            Response.AppendCookie(newCookie);
            Response.AppendHeader("X-XSS-Protection", "0");

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                /*
                 * string con = "Index";
                 * if (User.IsInRole("Sprzedawca")) con = "Sales";
                 * else if (User.IsInRole("Administrator")) con = "Admin";
                 * return RedirectToAction(con+"/Index");
                 */

                string controler = "Home"; //dla zwykłych klientów

                if (Roles.IsUserInRole(userName, "Administrator"))
                {
                    controler = "Admin";
                }
                else if (Roles.IsUserInRole(userName, "Sprzedawca"))
                {
                    controler = "sales";
                }
                return(RedirectToAction("Index", controler));
            }
        }
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);
            Session["CslaPrincipal"] = Csla.ApplicationContext.User;
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #23
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);

            User user = new User();

            if (userName == "Webmaster")
            {
                user.Role = UserRoles.Webmaster;
            }
            else if (userName == "AdminUser")
            {
                user.Role = UserRoles.Admin;
            }
            else
            {
                user.Role = UserRoles.Standard;
            }

            if (userName == "TrialUser")
            {
                user.Account = new TrialAccount();
            }
            if (userName == "PaidUser")
            {
                user.Account = new PaidAccount();
            }

            contextStore.Add(user);

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #24
0
        public override void DoProcessRequest(IExecutionContext context)
        {
            if (!ValidateRegistration())
            {
                return;
            }

            MembershipCreateStatus createStatus = MembershipService.CreateUser(username, password, email);

            if (createStatus == MembershipCreateStatus.Success)
            {
                FormsAuth.SignIn(username, false);
                context.Transfer("/home/index");
            }
            else
            {
                ReportError(null, ErrorCodeToString(createStatus));
            }
        }
        public ActionResult LogOn(LogonModel model)
        {
            string errorMessage = null;

            if (!ModelState.IsValid ||
                !model.Validate(out errorMessage, OrnamentContext.DaoFactory.MemberShipFactory.CreateUserDao(),
                                OrnamentContext.MemberShip.CurrentVerifyCode()))
            {
                if (errorMessage != null)
                {
                    ModelState.AddModelError("_form", errorMessage);
                }
                return(View(model));
            }
            FormsAuth.SignIn(model.User, model.RememberMe);
            return(!String.IsNullOrEmpty(model.ReturnUrl)
                ? (ActionResult)Redirect(model.ReturnUrl)
                : RedirectToAction("Index", "Home"));
        }
Beispiel #26
0
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {
            if (!ValidateLogOn(userName, password))
            {
                ViewData["rememberMe"] = rememberMe;
                return(View());
            }

            FormsAuth.SignIn(userName, rememberMe);
            TempData["flash"] = "Welcome " + userName + ". You are logged in.";
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Search", "SearchReview"));
            }
        }
Beispiel #27
0
        public object Login(JObject request)
        {
            var UserCode = request.Value <string>("usercode");
            var Password = request.Value <string>("password");

            //用户名密码检查
            if (String.IsNullOrEmpty(UserCode) || String.IsNullOrEmpty(Password))
            {
                return new { status = "error", message = "用户名或密码不能为空!" }
            }
            ;

            //用户名密码验证
            var pQuery = ParamQuery.Instance()
                         .Where("UserCode", UserCode)
                         .Where("Password", EncryptHelper.MD5(Password))
                         .Where("IsEnable", 1);
            var result = this.GetModel(pQuery);

            //验证密码
            if (result == null || String.IsNullOrEmpty(result.UserCode))
            {
                return new { status = "error", message = "用户名或密码不正确!" }
            }
            ;

            //调用框架中的登陆机制
            var loginer = new LoginerBase()
            {
                UserCode = result.UserCode, UserName = result.UserName
            };
            var effectiveHours = ConfigHelper.GetConfigInt("LoginEffectiveHours", 8);

            FormsAuth.SignIn(loginer, 60 * effectiveHours);

            //登陆后处理
            this.UpdateUserLoginCountAndDate(UserCode); //更新用户登陆次数及时间
            this.AppendLoginHistory(request);           //添加登陆履历

            //返回登陆成功
            return(new { status = "success", message = "登陆成功!" });
        }
Beispiel #28
0
        public ActionResult EmailAuthentication(string token)
        {
            bool isUserExist    = MembershipService.IsUserExist(token);
            bool isUserApproved = MembershipService.IsUserApproved(token);

            string pageName;

            if (isUserExist && !isUserApproved)
            {
                pageName = "AuthenticationSuccess";
                MembershipService.ApproveUser(token);
                FormsAuth.SignIn(MembershipService.GetUserName(token), false /* createPersistentCookie */);
            }
            else
            {
                pageName = "AuthenticationFailure";
            }

            return(RedirectToAction("Page", "Cms", new { pageName = pageName }));
        }
Beispiel #29
0
        public object Login(JObject request)
        {
            var UserCode = request.Value <string>("usercode");
            var Password = request.Value <string>("password");

            //用户名密码检查
            if (String.IsNullOrEmpty(UserCode) || String.IsNullOrEmpty(Password))
            {
                return new { status = "error", message = "用户名或密码不能为空!" }
            }
            ;

            //用户名密码验证
            var result = this.GetModel(ParamQuery.Instance()
                                       .AndWhere("UserCode", UserCode)
                                       .AndWhere("Password", Password)
                                       .AndWhere("IsEnable", true));

            if (result == null || String.IsNullOrEmpty(result.UserCode))
            {
                return new { status = "error", message = "用户名或密码不正确!" }
            }
            ;

            //调用框架中的登陆机制
            var loginer = new LoginerBase {
                UserCode = result.UserCode, UserName = result.UserName
            };

            var effectiveHours = ZConfig.GetConfigInt("LoginEffectiveHours");

            FormsAuth.SignIn(loginer.UserCode, loginer, 60 * effectiveHours);

            //登陆后处理
            this.UpdateUserLoginCountAndDate(UserCode); //更新用户登陆次数及时间
            this.AppendLoginHistory(request);           //添加登陆履历
            MmsService.LoginHandler(request);           //MMS系统的其它的业务处理

            //返回登陆成功
            return(new { status = "success", message = "登陆成功!" });
        }
Beispiel #30
0
        public ActionResult Register(string userName, string email, string password, string confirmPassword, byte department)
        {
            ViewData["Department"]     = LoadDataForDropDownList();
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                if (_accountController.CreateUser(userName, password, email, department))
                {
                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return(RedirectToAction("IndexForNews", "NguyenHiep"));
                }
                else
                {
                    ModelState.AddModelError("_FORM", "Register unsuccessful");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }