public async Task <ActionResult> Accept(AcceptViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var cmd = new AcceptInvitation(model.UserName, model.Password, model.InvitationKey) { AcceptedEmail = model.Email, FirstName = model.FirstName, LastName = model.LastName }; var identity = await _accountService.AcceptInvitation(this.ClaimsUser(), cmd); //TODO: Remove hack. // HERE since the message queue starts to process the events // before we are done with them. We need some way to stack up the publishing // until the current handler is done. // // can't use a message handler since we need a result from the invitation accept. // so that we can construct a new identity _uow.SaveChanges(); if (identity == null) { ModelState.AddModelError("", "Failed to find an invitation with the specified key. You might have already accepted the invitation? If not, ask for a new one."); _logger.Error("Failed to find invitation " + model.InvitationKey); return(View(new AcceptViewModel())); } await SignInAsync(identity); var url = Url.Content("~/"); return(RedirectToAction("UpdateSession", new { returnUrl = url })); }
public async Task HandleAsync(IMessageContext context, AcceptInvitation message) { await _accountService.AcceptInvitation(context.Principal, message); }