How to prevent YAF from storing user roles in table yaf_User column flags and instead always ask them from Roles Provider (it does so anyway - for example in order to display user groups. But actual user privileges are always the ones it got from provider at the very first request)

I have the same problem as here http://forum.yetanotherf...sue-with-Admin-user.aspx , but there is no answer in that topic.

For example the first time Roles Providers said that user has Admin and Registered users privileges. Then I have removed Admin privileges from that user and I want YAF to prevent this user from being able to admin the forum. How can I achieve this?
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
You will need to remove the flags from the yaf_User table. Currently, it's a "sync" system that I'd like to see removed.
It seems removing column is not that simple: there is a code dependency on that column that fails after the column is removed. It seems the only solution is to modify the source code
In case anyone else will encounter the same problem, here is the solution:

1. Open file YafContext.cs
2. Go to method named InitUserAndPage()
3. Find the following chunk of code

				if (this.User != null && (this.Get<HttpSessionStateBase>()["UserUpdated"] == null || this.Get<HttpSessionStateBase>()["UserUpdated"].ToString() != this.User.UserName))
					RoleMembershipHelper.UpdateForumUser(this.User, this.PageBoardID);
					this.Get<HttpSessionStateBase>()["UserUpdated"] = this.User.UserName;

and remove chahing, basically what i did was just placed the call to refresh user data at the very top of the method so it looks like

protected override void InitUserAndPage()
			RoleMembershipHelper.UpdateForumUser(this.User, this.PageBoardID);

			if (!this._initUserPage)

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