public ActionResult UpdateSpeakersAvatars() { string localImageUrl = @"/Content/Avatar/default_user_icon.jpg"; var defaultEvent = service.GetDefaultEvent(); int eventid = defaultEvent.ID; var speakers = service.GetSpeakers(eventid); foreach (var speaker in speakers) { Speaker sp = new Speaker() { ID = speaker.ID, Email = speaker.Email, Twitter = speaker.Twitter, ImageUrl = speaker.ImageUrl }; if (string.IsNullOrEmpty(speaker.ImageUrl)) { CodeCampService.Person person = service.FindPersonByEmail(sp.Email); person.ImageUrl = GetImageInfo(person.Twitter, localImageUrl); service.UpdatePerson(person); } } return(RedirectToAction("Index", "Administrator")); }
private void SetFormsAuth(CodeCampService.Person authenticatedPerson, bool rememberMe) { this.CurrentUser = authenticatedPerson.Map(); HttpContext.Session.Add("auth", true); HttpContext.User = CurrentUser; SetPersonRoles(this.CurrentUser); CreateAuthTicket(rememberMe); // FormsAuthentication.SetAuthCookie(CurrentUser.Email, false); // ??? }
public ActionResult LogOn(LogOnModel model, string returnUrl, FormCollection frm) { if (ModelState.IsValid) { CodeCampService.Person authenticatedPerson = null; CodeCampService.Person person = service.FindPersonByEmail(model.Email); if (person == null) { ModelState.AddModelError("", ""); return(View(model)); //RedirectToAction("LogOn", "Account"); } else { person.PasswordHash = HashProvider.ComputePasswordHash(model.Password); authenticatedPerson = service.Login(person); } if (authenticatedPerson != null) { bool rememberMe = frm["rememberMe"] == "on"; SetFormsAuth(authenticatedPerson, rememberMe); if (string.IsNullOrEmpty(authenticatedPerson.Location)) { return(RedirectToAction("UpdateProfile", "Account")); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(model)); }
public ActionResult Register(int eventId, RegisterModel model, FormCollection frm) { if (ModelState.IsValid) { ViewBag.TShirtSizes = repo.GetTShirtSizes(); if (IsDuplicateRegistration(model.Email)) { ModelState.AddModelError("Email", "The user at this email address is already registered."); return(View(model)); } if (!String.IsNullOrEmpty(model.Twitter)) { if (!model.Twitter.StartsWith("@")) { const string twitterPrefix = "@"; model.Twitter = string.Format("{0}{1}", twitterPrefix, model.Twitter); } } var newPerson = new CodeCampService.Person() { Email = model.Email, PasswordHash = UserNamePasswordHashProvider.ComputePasswordHash(model.Password), Twitter = model.Twitter, FirstName = model.FirstName, LastName = model.LastName, Location = model.Location, TShirtSize = model.TShirtSizeId }; bool useTwitter = frm["cbTwitter"] == "on"; if (model.Avatar != null) { newPerson.ImageUrl = GetImageInfo(model.Avatar, "/Content/avatar"); } else if (useTwitter) { newPerson.ImageUrl = GetImageInfo(model.Twitter, LocalImageUrl); } else { newPerson.ImageUrl = LocalImageUrl; } // service.RegisterPerson(newPerson); newPerson.ID = service.RegisterPerson(newPerson); // service.FindPersonByEmail(newPerson.Email).ID; service.Rsvp(eventId, newPerson.ID, "YES"); HttpContext.User = this.CurrentUser = newPerson.Map(); HttpContext.Session.Add("auth", true); //this.CurrentUser = newPerson.Map(); FormsAuthentication.SetAuthCookie(CurrentUser.Email, false); // ??? return(RedirectToAction("Index", "Home")); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Register(int eventId, RegisterModel model, FormCollection frm) { if (ModelState.IsValid) { ViewBag.TShirtSizes = repo.GetTShirtSizes(); if (IsDuplicateRegistration(model.Email)) { ModelState.AddModelError("Email", "The user at this email address is already registered."); return View(model); } if (!String.IsNullOrEmpty(model.Twitter)) { if (!model.Twitter.StartsWith("@")) { const string twitterPrefix = "@"; model.Twitter = string.Format("{0}{1}", twitterPrefix, model.Twitter); } } var newPerson = new CodeCampService.Person() { Email = model.Email, PasswordHash = UserNamePasswordHashProvider.ComputePasswordHash(model.Password), Twitter = model.Twitter, FirstName = model.FirstName, LastName = model.LastName, Location = model.Location, TShirtSize = model.TShirtSizeId }; bool useTwitter = frm["cbTwitter"] == "on"; if (model.Avatar != null) { newPerson.ImageUrl = GetImageInfo(model.Avatar, "/Content/avatar"); } else if (useTwitter) { newPerson.ImageUrl = GetImageInfo(model.Twitter, LocalImageUrl); } else { newPerson.ImageUrl = LocalImageUrl; } // service.RegisterPerson(newPerson); newPerson.ID = service.RegisterPerson(newPerson); // service.FindPersonByEmail(newPerson.Email).ID; service.Rsvp(eventId, newPerson.ID, "YES"); HttpContext.User = this.CurrentUser = newPerson.Map(); HttpContext.Session.Add("auth", true); //this.CurrentUser = newPerson.Map(); FormsAuthentication.SetAuthCookie(CurrentUser.Email, false); // ??? return RedirectToAction("Index", "Home"); } // If we got this far, something failed, redisplay form return View(model); }