YAFLogo

Posted by: degree11 - Monday, 26 October 2020 19:08:30
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

Posted by: tha_watcha - Tuesday, 27 October 2020 09:21:06
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.

Posted by: degree11 - Tuesday, 27 October 2020 10:53:43
.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.

Posted by: tha_watcha - Wednesday, 28 October 2020 09:45:54
[quote=degree11;72763].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.[/quote] 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.

Posted by: degree11 - Thursday, 29 October 2020 10:53:58
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.

Posted by: tha_watcha - Thursday, 29 October 2020 11:08:09
[quote=degree11;72767]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.[/quote] 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.

Posted by: degree11 - Friday, 13 November 2020 16:30:32
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: [code=csharp]this.PageContext.CurrentUserData.Membership[/code] is null so [i]My Account[/i] 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.

Posted by: degree11 - Tuesday, 17 November 2020 16:30:31
I've fixed the My account page access by adding a line in CombinedUserDataHelper in MembershipUser property: [code=csharp] if(this.membershipUser == null) { this.membershipUser = System.Web.Security.Membership.GetUser(); }[/code]

Posted by: tha_watcha - Wednesday, 18 November 2020 13:18:01
[quote=degree11;72804]I've fixed the My account page access by adding a line in CombinedUserDataHelper in MembershipUser property: [code=csharp] if(this.membershipUser == null) { this.membershipUser = System.Web.Security.Membership.GetUser(); }[/code][/quote] 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 [b]MembershipUser GetUser(string username, bool userIsOnline)[/b]

Posted by: degree11 - Thursday, 26 November 2020 15:26:40
Yes, I noticed it :) However it returns a user when I use this: [code=csharp]this.membershipUser = System.Web.Security.Membership.GetUser();[/code] Do you know why MembershipProvider.GetUser doesn't work and the above works?

Posted by: tha_watcha - Sunday, 29 November 2020 01:12:46
[quote=degree11;72812]Yes, I noticed it :) However it returns a user when I use this: [code=csharp]this.membershipUser = System.Web.Security.Membership.GetUser();[/code] [/quote] This would return the wrong user, for example when you edit a different user in the admin interface. [quote=degree11;72812]Do you know why MembershipProvider.GetUser doesn't work and the above works?[/quote] 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.