thowle
  • Posts: 11
  • Joined: 28/11/2013
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.".
squirrel
  • Posts: 925
  • Joined: 14/01/2010
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
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 925
  • Joined: 14/01/2010
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
  • Posts: 11
  • Joined: 28/11/2013
According to the source code of the role helper on YAF... https://github.com/YAFNE.../RoleMembershipHelper.cs 

I need to call the stored proc yaf_user_aspnet

I'll give this a try and report back.
thowle
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 925
  • Joined: 14/01/2010
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
  • Posts: 11
  • Joined: 28/11/2013
Originally Posted by: squirrel

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?



Seems like the case. Whatever the process; the end result is their bindings being removed from the user groups table.
thowle
  • Posts: 11
  • Joined: 28/11/2013
Also for some reason, the display name in users keeps going back to their e-mail address.
tha_watcha
  • Posts: 4037
  • Joined: 06/03/2010
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);

UserPostedImage
thowle
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 11
  • Joined: 28/11/2013
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
  • Posts: 11
  • Joined: 28/11/2013
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?

Forum Jump  
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.

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