YAFLogo

aikixd
  • aikixd
  • 51.8% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
I want to expand the registration system of the forum to other parts of my site.
I need to check wether the user is logged in and to check what group and acces mask he is in, from my own page. What classes and methods are used to do that?
And i would like to make a welcome message or login box outside of the forum control. is that possible?
And one more thing. Is there some kind of documentation for the source?
Sponsor

Soro_Trestal
14 years ago
Hi aikixd,

I used YAF.Classes.Data.DB there's a lot of cool stuff in the class

f.e. to see if the user has forums he can moderate:

Quote:

If YAF.Classes.Data.DB.forum_listallMyModerated("1", yafIntergrator.GetUserID(userName).Rows(0).Item("UserID").ToString).Rows.Count > 0 Then Me.lbModerate.Visible = True
End If



f.e to see if the user has the admin role:

Quote:

If Page.User.IsInRole("Groupname here") Then
Me.lbAdmin.Enabled = True
End If



i placed the forum inside a iframe on my parent site, and i used the membership system from YaF,
if you want to access the login system from outside the forum all you need to do is add a login control on your main site

If you have the forum open inside the iframe the forum will refresh and authenticate you

i did this on om my site:

Quote:

If Membership.ValidateUser(DirectCast(mvLogin.FindControl("myLogin").FindControl("UserName"), TextBox).Text, DirectCast(mvLogin.FindControl("myLogin").FindControl("Password"), TextBox).Text) Then
FormsAuthentication.SetAuthCookie(DirectCast(mvLogin.FindControl("myLogin").FindControl("UserName"), TextBox).Text, DirectCast(mvLogin.FindControl("myLogin").FindControl("RememberMe"), CheckBox).Checked)
else
.........
End if



to check if the user is logged in you can use:

Quote:

If Me.Page.User.Identity.IsAuthenticated Then
.... do the stuff when he is ...
else
.... do some other stuff
End If



Hope this helps,

Regards
aikixd
  • aikixd
  • 51.8% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
I couldn't find this part yafIntergrator.GetUserID(userName) for some reason
Soro_Trestal
14 years ago
Oops sry, it's a class i created to access the YaF DB from my Vb.net code

I used the function GetUserID to get the UserID from the logged in user

Public Function GetUserID(ByVal userName As String) As DataTable
Dim tempCon As New MySQLConnection("Data Source=.\SQLExpress;Initial Catalog=yafnet;Integrated Security=SSPI;")
Dim tempSql As String = "SELECT UserID FROM yaf_User where Name = '" & userName & "'"
tempCon.SetCommand(CommandType.Text, tempSql)
Dim tempTable As DataTable = tempCon.BeginTransaction("UserID")
If tempTable.Rows.Count > 0 Then
Return tempTable
End If
Return Nothing
End Function

Cheers !
aikixd
  • aikixd
  • 51.8% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
thanx, i ll give it a try 🙂
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
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