YAFLogo

netnush
  • netnush
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
Hi,

I have integrated YAF-v1.9.5 login with an existing site's members. The site uses email address to login to it. Therefore, I used email address as username in YAF database.

YAF.Providers.Membership.DB.Current.CreateUser(appName, userEmail, yafPassword, "", 0,

SessionContext.AuthenticatedMember.user_email, "", "",

true, providerKey));

FormsAuthentication.SetAuthCookie(userEmail, true);

The above works perfectly, but when you visit forum, it displays email address as the user name. The my client wants to create a separate username only for forum. That means, after a member logs in to the system, if the clicks the forum menu, the system should popup a form to enter a username.

I've done that by creating a new flag in YAF membership table. Once it updates the member username, i set the AuthCookie with new username and redirect the member to forum page.

FormsAuthentication.SetAuthCookie(userName, true);

Response.Redirect("/forum");

The problem is, once the member is redirected to the forum page, the form doesn't display the new user name. It displays the old user name even though the database is updated.

Can someone please help to overcome this?

Thanks in advance.

Sponsor
netnush
  • netnush
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
Please can someone help me with this?

I even tried to signout and remove cache before i set the auth cookie with new user name. But it didn't work either

FormsAuthentication.SignOut();

YafContext.Current.Cache.Remove(YafCache.GetBoardCacheKey(YAF.Classes.Constants.Cache.ActiveUserLazyData.FormatWith(YafContext.Current.CurrentUserData.UserID)));

YafContext.Current.Cache.Remove(YafCache.GetBoardCacheKey(YAF.Classes.Constants.Cache.UsersOnlineStatus));

FormsAuthentication.SetAuthCookie(userEmail, true);

netnush
  • netnush
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
At last I found it, just call this method

UserMembershipHelper.ClearCacheForUserId(long userId)