YAFLogo

Alexey_Polyakov
12 years ago
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)

http://forum.yetanotherforum.net/yaf_postst14160_Integration-Issue-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?

Sponsor
Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
12 years ago
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.
Alexey_Polyakov
12 years ago
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
Alexey_Polyakov
12 years ago
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)
			{