public IActionResult Register(User newuser) { if (ModelState.IsValid) { var check = userFactory.FindByEmail(newuser.email); if (check != null) { ViewBag.ManualError = "This email is already registered"; ViewBag.Errors = ModelState.Values; return(View("Index")); } PasswordHasher <User> Hasher = new PasswordHasher <User>(); newuser.password = Hasher.HashPassword(newuser, newuser.password); userFactory.Add(newuser); check = userFactory.FindByEmail(newuser.email); HttpContext.Session.SetInt32("id", (int)check.Id); ViewBag.first_name = check.first_name; ViewBag.last_name = check.last_name; ViewBag.Errors = ModelState.Values; return(View("addquote")); } ViewBag.Errors = ModelState.Values; return(View("Index")); }
public IActionResult AddUser(User user) { _uFactory.Add(user); ViewData["Message"] = "Your contact page."; return(RedirectToAction("Index")); }
public IActionResult Register(User newUser) { ViewBag.EmailError = null; if (ModelState.IsValid) { var checkuser = userFactory.GetUserByEmail(newUser.email); if (checkuser != null) { ViewBag.EmailErrors = "This Email Address is already registered."; return(View("Main")); } else { var Hasher = new PasswordHasher <User>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); userFactory.Add(newUser); User CurrentUser = userFactory.GetLatestUser(); HttpContext.Session.SetInt32("CurrUserId", CurrentUser.id); return(RedirectToAction("Ideas")); } } ViewBag.Errors = ModelState.Values; return(View("Main")); }
public IActionResult Register(UserViewModel model) { User newUser = new User { Name = model.Name, Username = model.Username, Email = model.Email, Password = model.Password, }; if (ModelState.IsValid) { if (userFactory.FindByUsername(newUser.Username) == null) { userFactory.Add(newUser); HttpContext.Session.SetString("success", "User registered - Please log in!"); return(RedirectToAction("Index")); } else { ViewBag.errors = "User already exists!"; return(View("Index", model)); } } else { return(View("Index", model)); } }
public IActionResult Add(Trail trail) { if (ModelState.IsValid) { _userFactory.Add(trail); } Console.WriteLine("i am in side Add function!"); return(View("Index", trail)); }
public IActionResult Create(User user) { if (ModelState.IsValid) { _userFactory.Add(user); return(RedirectToAction("Users")); } return(View("Index")); }
public IActionResult Register(RegisterViewModel regModel) { if (ModelState.IsValid) { User newUser = userfactory.Add(regModel); HttpContext.Session.SetInt32("userid", newUser.id); return(RedirectToAction("Index")); } return(View("Register")); }
public IActionResult Create(Quotes quote) { if (ModelState.IsValid) { userFactory.Add(quote); return(RedirectToAction("Home")); } ViewBag.errors = ModelState.Values; return(View("Index")); }
public IActionResult createuser(User NewUser) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); NewUser.password = Hasher.HashPassword(NewUser, NewUser.password); userFactory.Add(NewUser); return(RedirectToAction("wall")); } ViewBag.Errors = ModelState.Values; return(View("register")); }
public IActionResult RegisterMethod(User item) { if (ModelState.IsValid) { userFactory.Add(item); User user = userFactory.FindByEmail(item.email); HttpContext.Session.SetInt32("userid", (int)user.id); return(Redirect("/wall")); } ViewBag.registererrors = ModelState.Values; return(View("Index")); }
public IActionResult Register(Home model) { if (!ModelState.IsValid) { return(View("Index", model)); } PasswordHasher <Home> Hasher = new PasswordHasher <Home>(); model.Password = Hasher.HashPassword(model, model.Password); userFactory.Add(model); ViewBag.message = "Success"; return(View()); }
public IActionResult Register(User model) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); model.password = Hasher.HashPassword(model, model.password); _userFactory.Add(model); User CurrentUser = _userFactory.GetLatestUser(); HttpContext.Session.SetInt32("CurrUserId", CurrentUser.UserId); return(RedirectToAction("Success")); } ViewBag.errors = ModelState.Values; return(View("Index")); }
public IActionResult Register(RegisterViewModel regModel) { if (ModelState.IsValid) { User newUser = userFactory.Add(regModel); if (newUser == null) { ViewBag.register_error = "Email address already in use."; return(View("register")); } HttpContext.Session.SetInt32("id", newUser.id); return(Redirect("bright_ideas")); } return(View("register")); }
public IActionResult Method(User newUser) { TryValidateModel(newUser); if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); userFactory.Add(newUser); User user = userFactory.FindByEmail(newUser.email); HttpContext.Session.SetInt32("id", (int)user.Id); return(RedirectToAction("show")); } ViewBag.Errors = ModelState.Values; return(View("index")); }
public IActionResult Register(User newUser) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); userFactory.Add(newUser); var user = userFactory.FindbyEmail(newUser.email); int user_id = (int)user.id; HttpContext.Session.SetInt32("user_id", user_id); return(Redirect("message")); } // return View(user); return(View(newUser)); }
public IActionResult Register(User newUser) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); userFactory.Add(newUser); userFactory.FindbyEmail(newUser.email); var user = userFactory.FindbyEmail(newUser.email); HttpContext.Session.SetInt32("user_id", (int)user.id); HttpContext.Session.SetString("first_name", (string)user.first_name); return(Redirect("groups")); } else { return(View("Login")); } }
public IActionResult Register(User model) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); model.password = Hasher.HashPassword(model, model.password); _userFactory.Add(model); User CurrentUser = _userFactory.GetLatestUser(); HttpContext.Session.SetInt32("CurrUser_id", CurrentUser.user_id); return(RedirectToAction("Show")); } ViewBag.Errors = new List <string>(); foreach (var error in ModelState.Values) { if (error.Errors.Count > 0) { string errorcode = (error.Errors[0].ErrorMessage); ViewBag.Errors.Add(errorcode); } } return(View("Login")); }
public IActionResult Register(User user) { if (userFactory.FindByEmail(user.email) == null) { if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); user.pwd = Hasher.HashPassword(user, user.pwd); userFactory.Add(user); var founduser = userFactory.FindByEmail(user.email); HttpContext.Session.SetInt32("userId", founduser.id); HttpContext.Session.SetString("fname", user.fname); return(RedirectToAction("Wall")); } return(View("Index")); } else { ViewBag.error = "User already exists"; return(View("Index")); } }
public IActionResult Register(RegUser newUser) { if (ModelState.IsValid) { PasswordHasher <RegUser> Hasher = new PasswordHasher <RegUser>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); User user = new User { firstname = newUser.firstname, lastname = newUser.lastname, email = newUser.email, username = newUser.username, password = newUser.password }; _UserFactory.Add(user); User CurrentUser = _UserFactory.GetLatestUser(); HttpContext.Session.SetInt32("CurrUserId", CurrentUser.Userid); return(RedirectToAction("dashbord", "Message")); } ViewBag.Errors = ModelState.Values; return(View("RegisterPage")); }
public IActionResult Register(User NewUser) { errors.Clear(); //clear out all errors to begin whichErr = null; //reset whichErr User checkUser = userFactory.FindByEmail(NewUser.email); //create a User object and attempt to retrieve user information based on the entered email address if (ModelState.IsValid) //if the data entered in the inputs meets the min requirements as set forth in the User class in models... { if (checkUser != null) //if a user is retrieved based on the entered email address.. { errors.Add("User already exists, please log in."); //add this error to the errors list whichErr = "reg"; //set whichErr to a registration error } else //if a user is not retrieved... { PasswordHasher <User> Hasher = new PasswordHasher <User>(); //create a new PasswordHasher object NewUser.password = Hasher.HashPassword(NewUser, NewUser.password); //set the NewUser's password attribute to a hashed version of the entered password userFactory.Add(NewUser); //send the NewUser object (with populated information) to the userFactory to add to the DB currUser = NewUser; //set currUser to the NewUser object with the hashed password return(RedirectToAction("Success")); //return to the Success page } } else //if the data entered in the inputs does not meet the min requirements... { foreach (var error in ModelState.Values) //for every object in the list of ModelState.Values { if (error.Errors.Count > 0) //assuming the Error count is greater than 0 { string errorMess = (string)error.Errors[0].ErrorMessage; //create a string to store each error message errors.Add(errorMess); //add that message to the errors list whichErr = "reg"; //set whichErr to a registration error } } } return(RedirectToAction("Index")); //return the user to Index }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { VShopConfig vsconfig = VShopConfigHelper.Get(); //获取从wxProcess.aspx传递过来的跳转地址reurl if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "") { reurl = Request.QueryString["reurl"].ToString(); } string code = ""; if (Request.QueryString["code"] != null && Request.QueryString["code"] != "") { //获取微信回传的code code = Request.QueryString["code"].ToString(); OAuth_Token Model = Get_token(code); //获取token OAuthUser OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid); if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息 { //在页面上输出用户信息 //Response.Write("用户OPENID:" + OAuthUser_Model.openid + "<br>用户昵称:" + OAuthUser_Model.nickname + "<br>性别:" + OAuthUser_Model.sex + "<br>所在省:" + OAuthUser_Model.province + "<br>所在市:" + OAuthUser_Model.city + "<br>所在国家:" + OAuthUser_Model.country + "<br>头像地址:" + OAuthUser_Model.headimgurl + "<br>用户特权信息:" + OAuthUser_Model.privilege); //先判断该用户之前是否注册过 UserModel oLoginUser = UserFactory.Get(OAuthUser_Model.openid); if (oLoginUser == null) //没注册,则重新注册一个 { UserModel regu = new UserModel(); regu.openid = OAuthUser_Model.openid; regu.nickname = Utils.RemoveEmoji(OAuthUser_Model.nickname); regu.sex = OAuthUser_Model.sex == "1" ? "男性" : "女性"; regu.headpicurl = OAuthUser_Model.headimgurl; regu.address = string.Empty; //OAuthUser_Model.province + OAuthUser_Model.city; UserFactory.Add(regu); oLoginUser = UserFactory.Get(OAuthUser_Model.openid); OdnShop.Core.PageControler.WebPageBase.WriteUidCookie(oLoginUser.uid, 0); if (reurl.ToLower().IndexOf("share.aspx") >= 0) { reurl += "®new=1"; } } else //有注册过 { oLoginUser.headpicurl = OAuthUser_Model.headimgurl; UserFactory.Update(oLoginUser); OdnShop.Core.PageControler.WebPageBase.WriteUidCookie(oLoginUser.uid, 0); } //或跳转到自己的页面,想怎么处理就怎么处理 Response.Redirect(reurl); } else //未获得openid,回到原始页面 { Response.Redirect(reurl); } } } }
public IActionResult Posting(User user) { userFactory.Add(user); return(RedirectToAction("showing")); }
protected void Submit_click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(email.Text) && !string.IsNullOrEmpty(password.Text) && !string.IsNullOrEmpty(passwordConfirmation.Text) && !string.IsNullOrEmpty(firstname.Text) && !string.IsNullOrEmpty(lastname.Text)) { if (email.Text.Length > 50 || lastname.Text.Length > 40 || firstname.Text.Length > 40 || password.Text.Length > 40 || passwordConfirmation.Text.Length > 40) { notification.Style.Add("color", "red"); notification.InnerText = "Les données sont trop longues"; notification.Visible = true; } else { UserFactory uf = new UserFactory(cnnStr); User user = uf.GetByEmail(email.Text); if (user != null) { notification.Style.Add("color", "red"); notification.InnerText = "Un compte existe déjà pour cette adresse e-mail"; notification.Visible = true; } else { System.Text.RegularExpressions.Regex regexDate = new Regex(@"^\d{2}-\d{2}-\d{4}$"); System.Diagnostics.Debug.WriteLine(birthday.Text); if (!regexDate.IsMatch(birthday.Text)) { notification.Style.Add("color", "red"); notification.InnerText = "La date de naissance doit correspondre à jj-mm-aaaa"; notification.Visible = true; } else if (password.Text.Length < 6) { notification.Style.Add("color", "red"); notification.InnerText = "Le mot de passe doit contenir au moins 6 caractères"; notification.Visible = true; } else if (password.Text != passwordConfirmation.Text) { notification.Style.Add("color", "red"); notification.InnerText = "Les deux mots de passe doivent être identiques"; notification.Visible = true; } else { bool sub; if (verifNotification == true) { sub = subscriber.Checked; } else { sub = false; } DateTime birthdayDate = Convert.ToDateTime(DateTime.ParseExact(birthday.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture)); string token = rndToken(40); uf.Add(lastname.Text, firstname.Text, email.Text, password.Text, false, sub, false, birthdayDate, token); notification.Style.Add("color", "green"); notification.InnerText = "Bienvenue ! Un e-mail vous a été envoyé afin de confirmer votre inscription"; notification.Visible = true; EmailController ec = new EmailController(); string body = string.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/Email/ActivationEmail.html"))) { body = reader.ReadToEnd(); } string strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery; string strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/"); string lienActivation = strUrl + "Activation.aspx" + "?email=" + email.Text + "&tkn=" + token; body = body.Replace("{lienActivation}", lienActivation); ec.SendMail(email.Text, "Bienvenue !", body); } } } } }