YAFLogo

thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Hey guys,

Have an issue -- I created a custom membership provider.. which, was a pain to get to work but finally seems to. My issue now, is that on the login event I check to see if the user has an account with the forum (yaf_User), if not -- I create one with an insert statement; then I get that UserID, and insert a new row into yaf_UserGroup, which gives them the default registered access.

My issue seems to be that randomly the information gets deleted; and in fact, the DisplayName in the users table seems to get overwritten sometimes as well.

IS this a cache issue? Does the information for new users or groups go somewhere else and get written to the db later?

I also tried adding rows into the prob_RoleMembership for the user, with no luck.

I'm using the default Role provider.

The only group binding that still exists, is the one for guest.

When logging in as the user(s) that no longer have the group binding, there is an error displayed on the UI "Failure There has been a system error processing your request. Please contact the forum admin explaining what you were doing when it happened.".

Sponsor
squirrel
11 years ago
You might try executing YAF's stored procedures for adding a member that way - instead of going direct into the database with Insert statements. YAF Stored Procedures I believe will have necessary triggers or multi-step inserts to keep indices in line and role membership as well.

You might look at the C# Sample application on GitHub for reference. tha_watcha may also shed more light on subject - he is integration special through work with DNN.


If you can't find it using the forum search, try my signature link -- searches this site using Google: Google is my Friend 
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Thanks for the reply; I'll give that a try. I saw some references in other forum posts to some columns, and stored procs that don't exist in this latest build.

I'll try to piece together what I see as being called when a new user is registered from YAF.

squirrel
11 years ago
Somewhere here in the forums, it's been documented what methods are called inside YAF's code to register a user outside of YAF -- maybe through that would lead to the procedures called, or maybe utilizing YAF's classes to accomplish what you need via parameters in your code, etc. Hope it helps 🙂 Might try the Integration forums --


If you can't find it using the forum search, try my signature link -- searches this site using Google: Google is my Friend 
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Looks like that for sure helped with correct account creation and role assignment. However, there is still an issue now where upon certain points the roles for the active user will disappear from the table. Then once you logout, and login again it throws that generic error (and event log shows failure to find guest account).

Once I re-add the roles and group bindings to the user, it's back to normal.

thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Still no luck.

Only thing else I can think to do, which is for sure not a fix -- but in the membership provider on login to check if the user has any groups, if not -- assign them based on permissions known by membership... but that's a really horrible way of working around this.

squirrel
11 years ago
It sounds like when you are 'logging in your user in YAF, roles are logged in with that user, but when the user has a statistics update, or logs out, those roles aren't being re-transferred back to the role-manager storage and recorded/updated with any changes?


If you can't find it using the forum search, try my signature link -- searches this site using Google: Google is my Friend 
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago

It sounds like when you are 'logging in your user in YAF, roles are logged in with that user, but when the user has a statistics update, or logs out, those roles aren't being re-transferred back to the role-manager storage and recorded/updated with any changes?

Originally Posted by: squirrel 

Seems like the case. Whatever the process; the end result is their bindings being removed from the user groups table.

thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Also for some reason, the display name in users keeps going back to their e-mail address.
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
11 years ago
For the role problem, there are two steps to be done if you want to add the user to a role

1. add the user to the user group table inside yaf

LegacyDb.usergroup_save(yafUserId, roleID, true);

2. add the user to the role in the ASP.NET Membership tables

if (!RoleMembershipHelper.IsUserInRole(userName, roleName))
            {
                RoleMembershipHelper.AddUserToRole(userName, roleName);
            }

and to resolve the displayname problem. if you want to update the display name you have to call the method....

LegacyDb.user_save(
                yafUserId,
                boardId,
                null,
                displayName,
                null,
                yafUserData.TimeZone,
                yafUserData.LanguageFile,
                yafUserData.CultureUser,
                yafUserData.ThemeFile,
                yafUserData.TextEditor,
                yafUserData.UseMobileTheme,
                null,
                null,
                null,
                yafUserData.DSTUser,
                yafUserData.IsActiveExcluded,
                null);
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Thanks for the information.

I'm not actually changing the display name. I allow them to do so in the forum. Once they save it.. after a while, the forum will remove them from the user group table, and reset their display name on it's own.

thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Every now and then you will be logged in, browsing the forum, then it just logs you out and shows that generic error. At this time, if I look in the usergroups folder, all assignments for that user are gone. Also in the user table, the display name is reset to their e-mail address.
thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Seems that the last method invoked on the membership provider before I get the error (below) is "GetUser". This method seems fine; however I'm assuming when yaf wants a session to expire it deletes the sessionid from the "active" and "activeaccess" table; this causes the error below. This appears to be happening often; causing an error, and also the "users" table to change the display name of that user to their e-mail address.

Failure

There has been a system error processing your request. Please contact the forum admin explaining what you were doing when it happened.

Continue...

thowle
  • thowle
  • 56.6% (Neutral)
  • YAF Camper Topic Starter
11 years ago
Does the Display name internally get over-written at any point in time with the username, or e-mail address? Or perhaps, does it ever get updated or over-written by anything returned from the membership provider?