public async Task <ActionResult> Register(RegisterViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, CreateDate = DateTime.Now, FirstName = model.FirstName, LastName = model.LastName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, "User"); if (!String.IsNullOrWhiteSpace(Request.QueryString.Get("i"))) { BLLUsers.AutoConfirmUser(user.Id); var invit = Guid.Parse(Request.QueryString.Get("i")); var invitObj = BLLInvitations.GetInvitation(invit); BLLConflicts.AddUserInConflictFromInvitation(user.Email, invit, user.Id); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); OpenFireConnector.Connector connector = new OpenFireConnector.Connector("http://openfire-444e60hk.cloudapp.net:9090/", "admin", "SF211084agantio"); connector.CreateUser(new OpenFireConnector.user() { password = user.Email, username = user.FirstName.Replace(" ", ".").ToLower() + "." + user.LastName.Replace(" ", ".").ToLower(), email = user.Email }); return(RedirectToAction("Identification", "Conflict", new { conflictId = invitObj.IdConflict, idUser = user.Id })); } else { BLLUsers.AutoConfirmUser(user.Id); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); if (!String.IsNullOrWhiteSpace(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // Guid guid = Guid.NewGuid(); // FastArbitreEmails.ConfirmAccount(model.Email, model.FirstName + " " + model.LastName, callbackUrl, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); //// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); // return View("ShouldConfirmEmail"); } // Send an email with this link } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> ConfirmEmail(string userId, string code, string captchaConfirm) { ViewBag.userId = userId; ViewBag.code = code; var result = await UserManager.ConfirmEmailAsync(userId, code); if (result.Succeeded) { if (Session["oi3_C309"] != null) { var user = await UserManager.FindByEmailAsync(Session["oi3_C309"].ToString()); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); OpenFireConnector.Connector connector = new OpenFireConnector.Connector("http://openfire-444e60hk.cloudapp.net:9090/", "admin", "SF211084agantio"); connector.CreateUser(new OpenFireConnector.user() { password = user.Email, username = user.FirstName.ToLower() + "." + user.LastName.ToLower(), email = user.Email }); return(RedirectToAction("Create", "Conflict", new { firstname = user.FirstName, lastname = user.LastName, email = user.Email })); } } if (result.Succeeded) { var user = UserManager.FindById(userId); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Profil")); } else { return(RedirectToAction("Error")); } }
public ActionResult StartDebate(int conflictId, int eventId, string debatType, string mailTitle, string mailBody, string visioTitle, string visioDescription, DateTime?rdv, int?debatTime) { var debate = new Debate(); debate.CreateDate = DateTime.Now; debate.IdEvent = eventId; debate.CountDown = debatTime; debate.Type = debatType == "mail" ? (int)DebateTypeEnum.Mail : (int)DebateTypeEnum.Visio; debate.Title = debate.Type == (int)DebateTypeEnum.Mail ? mailTitle : visioTitle; debate = BLLDebates.CreateDebate(debate); if (debate.Type == (int)DebateTypeEnum.Mail) { var mailDebate = new MailDebate(); mailDebate.CreateDate = DateTime.Now; mailDebate.CreatedBy = User.Identity.GetId(); mailDebate.IdDebate = debate.Id; mailDebate.Body = mailBody; mailDebate = BLLDebates.AddMailDebate(mailDebate); if (debate.MailDebates == null) { debate.MailDebates = new List <MailDebate>(); } foreach (var item in BLLDebates.GetUsersForDebate(debate.Id)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } debate.MailDebates.Add(mailDebate); return(RedirectToAction("MailDebate", new { debatId = debate.Id })); } else if (debate.Type == (int)DebateTypeEnum.Visio) { var conflict = BLLConflicts.GetConflictWithUsers(conflictId); var chatRoom = new ClickNClaim.OpenFireConnector.chatRoom(debate.Title, visioDescription, rdv.Value); OpenFireConnector.Connector connector = new OpenFireConnector.Connector("http://openfire-444e60hk.cloudapp.net:9090/", "admin", "SF211084agantio"); foreach (var item in conflict.UsersInConflicts) { var visioDebate = new MeetingDebate(); visioDebate.CreateDate = DateTime.Now; visioDebate.Date = rdv.Value; visioDebate.Description = visioDescription; // visioDebate.IdUser = item.IdUser; visioDebate.Link = "https://openfire-444e60hk.cloudapp.net:7443/ofmeet/?b=1-1461653024012"; visioDebate.Title = debate.Title; //visioDebate.IdDebate = debate.Id; //visioDebate = BLLDebates.AddMeetingDate(visioDebate); //if (debate.MeetingDebates == null) //{ // debate.MeetingDebates = new List<MeetingDebate>(); //} //debate.MeetingDebates.Add(visioDebate); var user = BLLUsers.GetUserById(item.IdUser); var existingUserInOpenFire = connector.UserExists(user.DisplayName.Replace(" ", ".")); if (existingUserInOpenFire == null) { existingUserInOpenFire = connector.CreateUser(new OpenFireConnector.user() { email = user.Email, name = user.DisplayName.Replace(' ', '.'), password = user.Email, username = user.DisplayName.Replace(' ', '.') }); } chatRoom.members.Add(new OpenFireConnector.member() { value = user.DisplayName.Replace(" ", ".").ToLower() + "@openfire" }); Guid guid = Guid.NewGuid(); FastArbitreEmails.VisioConferencePlanned(user.Email, rdv, visioTitle, visioDescription, connector.RoomLink + chatRoom.naturalName, user.DisplayName.Replace(" ", ".").ToLower(), user.Email, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } if (chatRoom.members.Where(c => c.value == conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire").FirstOrDefault() != null) { chatRoom.members.RemoveAll(c => c.value == conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire"); } chatRoom.owners.Add(new OpenFireConnector.owner() { value = conflict.Arbiter.DisplayName.Replace(" ", ".") + "@openfire" }); var link = connector.CreateChatroom(chatRoom); connector = null; } return(RedirectToAction("Conflict", "Viewer", new { conflictId = conflictId })); }