YAFLogo

degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
I'm new to yaf.NET and I am trying to figure out how the login and authentication work.

I can't see much resources about it or the threads are ancient. I am running the newest source c ode version.

I tried to debug but it doesn't seem to hit login.aspx.cs or signin method at all.

I can see it uses Logout.aspx.cs on logout, but not the above login.

Can you point me in to the right direction please?

Ultimately I want to replace buil-in login with our website membership provider so need to figure out how it works on yaf.NET initially.

An advice how to set it up would be welcomed too.

Thanks

Sponsor
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
3 years ago
What exactly is the problem? If you want to login the user in to the forum you need to use the forums login page, then it will use the membership provider of your existing site and creates the forum user automatically.
degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
.1 The problem is that I don't know how the authentication works because I am unable to find login classes that are getting hit by the debugger.

2. Also the problem is that I do not know how to replace the existing YAF authentication by our own one - because I am unable to find where the authentication happens in YAF source code - see first problem above.

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
3 years ago

.1 The problem is that I don't know how the authentication works because I am unable to find login classes that are getting hit by the debugger.

2. Also the problem is that I do not know how to replace the existing YAF authentication by our own one - because I am unable to find where the authentication happens in YAF source code - see first problem above.

Originally Posted by: degree11 

Not sure if i can really help you.. But if you looking for the login it is don in the login.ascx.cs or the LoginBox.ascx.cs.

degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
Yeah, I've already found LoginBox so can debug but still not sure how to integrate with custom authentication.

One of the features listed on the YAF home page is "YAF.NET forum is an embeddable (ascx) user-control and supports ASP.NET Membership making integration into DNN, MojoPortal, Umbraco, SharePoint and custom solutions possible." but there seem not to be any sort of documentation how to actually do it.

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
3 years ago

Yeah, I've already found LoginBox so can debug but still not sure how to integrate with custom authentication.

One of the features listed on the YAF home page is "YAF.NET forum is an embeddable (ascx) user-control and supports ASP.NET Membership making integration into DNN, MojoPortal, Umbraco, SharePoint and custom solutions possible." but there seem not to be any sort of documentation how to actually do it.

Originally Posted by: degree11 

Yes i know that, but be aware that this is an open source community software forum. I cant do everything alone here. And i can only provide solutions for solutions i know like dnn, where a module exist for yaf.

But if you your website is using the old classic asp.net membership then integrating would be possible relatively easy because then yaf uses the membersip provider defined in the web.config.

There also exist the YAF.Sample Application which is a basic example of how to integrate yaf in to a existing website.

Other then that without knowing the website or the cms (if any is used) i cant help much.

degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
So how to use our custom membership?

Just replace membership provider in web.config?

We basically added our membership provider and made it default provider which works fine (our membership users can login on the forum) except that:

this.PageContext.CurrentUserData.Membership

is null so My Account page throws runtime error when trying to read membership user email etc.

And also I've been trying to add our user to give admin rights but it doesn't work -

see my post here

https://www.yetanotherforum.net/forum/Posts/t21837-Set-admin-in-the-database 

- the user is not seen as admin.

degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
I've fixed the My account page access by adding a line in CombinedUserDataHelper in MembershipUser property:

                if(this.membershipUser == null)
                {
                    this.membershipUser = System.Web.Security.Membership.GetUser();
                }
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
3 years ago

I've fixed the My account page access by adding a line in CombinedUserDataHelper in MembershipUser property:

                if(this.membershipUser == null)
                {
                    this.membershipUser = System.Web.Security.Membership.GetUser();
                }

Originally Posted by: degree11 

If the Membership User is null at this point then it means that user Membership Provider returns null for the current User on the Method MembershipUser GetUser(string username, bool userIsOnline)

degree11
  • degree11
  • 61.4% (Friendly)
  • YAF Camper Topic Starter
3 years ago
Yes, I noticed it :)

However it returns a user when I use this:

this.membershipUser = System.Web.Security.Membership.GetUser();

Do you know why MembershipProvider.GetUser doesn't work and the above works?

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
3 years ago

Yes, I noticed it :)

However it returns a user when I use this:

this.membershipUser = System.Web.Security.Membership.GetUser();

Originally Posted by: degree11 

This would return the wrong user, for example when you edit a different user in the admin interface.

Do you know why MembershipProvider.GetUser doesn't work and the above works?

Originally Posted by: degree11 

No, sorry. I dont know the source of your Provider. You would need to debug it too find out why it doesn't return a user.