/// <summary> /// Create an appropriate redirect uri for unauthenticated user email confirm request /// </summary> /// <param name="uh">Hash of unauthenticated user id</param> /// <param name="result">The confirm entity result</param> /// <returns>Redirect Uri</returns> private Uri HandleUnauthEmailConfirmed(string uh, ConfirmEntityResult result) { Uri redirectUri = null; //Mark the unauthenticated user email as confirmed _usersDal.UpdateUserEmail(result.UserId.Value, result.EntityId, true); User user = _usersDal.GetUserByUserId(result.UserId.Value); if (user != null) { //Check if the user's account is already linked and return the appropriate authentication provider info. if (!string.IsNullOrEmpty(user.MsId)) { redirectUri = user.MsId.IndexOf(FbIdPattern, StringComparison.OrdinalIgnoreCase) != -1 ? new Uri(_bingOffersBaseUri, string.Format(UnauthEmailConfirmAccountLinkedPage, Facebook)) : new Uri(_bingOffersBaseUri, string.Format(UnauthEmailConfirmAccountLinkedPage, Microsoft)); } else { Tuple <string, int> confirmationResponse = _usersDal.CreateConfirmationCode(user.Id.ToString(), EntityType.AccountLink, user.Id); redirectUri = new Uri(_bingOffersBaseUri, string.Format(UnauthEmailConfirmAccountNotLinkedPage, uh, confirmationResponse.Item2)); } } Log.Verbose("Email Confirmed and updated for user. User Id={0} ", result.UserId); return(redirectUri); }
/// <summary> /// Get the link to be embedded in auth email if necessary. /// </summary> /// <param name="entityType"> /// Entity Type for link generation /// </param> /// <param name="user"> /// User object /// </param> /// <param name="environmentType"> /// Environment Type /// </param> /// <returns> /// Returns the Uri. /// </returns> private static Uri LinkingOrVerificationUrl(EntityType entityType, User user, IUsersDal dal, EnvironmentType environmentType) { Tuple <string, int> confirmationCodeTuple = dal.CreateConfirmationCode(user, entityType); return(ConfirmationLinkGenerator.GetLink(confirmationCodeTuple.Item1, confirmationCodeTuple.Item2, entityType, environmentType)); }