netnush
  •  netnush
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
2011-05-05T05:16:58Z
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.
Quote:


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.
Quote:


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
2011-05-05T23:14:40Z
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

Quote:


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
2011-05-06T07:02:28Z
At last I found it, just call this method

Quote:

UserMembershipHelper.ClearCacheForUserId(long userId)

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved