YAFLogo

guest
  • guest
  • Guest Topic Starter
16 years ago
Hi, I've just recently downloaded and installed YAF for a client, but I'm having a little bit of trouble integrating it into the current project. Authentication( with yaf stored procedure) works fine but its not setting the cookie to authenticate the user on the forum, although the code is almost the same as the login.acx page. heres the source if anyones interested.

If NewUser.DeCrypt(NewUser.password) = UCase(txtPassword.Text) Then
                    Dim dl As New DataLayer()
                    Dim params As Object() = {1, txtUserID.Text,FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.ToUpper(), "md5")}
                    Dim uID As Integer = dl.execScalar("yaf_user_login", params)
                    If uID > 0 Then
                        Dim idName As String = String.Format("{0};{1};{2}", uID, 1, txtUserID.Text)


                        'User is valid...
                        Label1.Text = NewUser.FirstName & " " & NewUser.LastName

                        LoadSessionVariables(NewUser)
                        FormsAuthentication.SetAuthCookie(idName, False)
                        Response.Redirect("main.aspx", False)
                    End If
it all executes fine and returns the uID but its not setting the session. both folders are virtual directories the yaf forum is located in the root/forum/ folder. Thanks.
Sponsor

Ederon
  • Ederon
  • 100% (Exalted)
  • YAF Developer
16 years ago
If you want to share authentication, you have to use the same authentication settings in web.config IIRC.
When I post FP:Ederon in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting.
guest
  • guest
  • Guest Topic Starter
16 years ago
hmm, could you provide an example of this? Thanks for the help its much appreciated.
Ederon
  • Ederon
  • 100% (Exalted)
  • YAF Developer
16 years ago
web.config of both applications should share this part.
	<system.web>

		...

		<authentication mode="Forms">
			<forms name=".YAFNET_Authentication" protection="All" timeout="43200" cookieless="UseCookies"/>
		</authentication>

		<machineKey validationKey="YOUR_KEY" decryptionKey="YOUR_KEY" validation="SHA1"/>

		...

	<system.web>

When I post FP:Ederon in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting.
guest
  • guest
  • Guest Topic Starter
16 years ago
Yes! worked perfectly, thank you very much sir. :d
Kai2
  • Kai2
  • 60.2% (Friendly)
  • YAF Camper
15 years ago
Great! The machinekey-entry also fixed my problem, thanks a lot 😎 Just in case anyone else needs it: Here  is a quite useful article about machine keys, especially the MachineKey Generator  was a big help for me. :idea: You only need to copy the generate lines to both your application and YAF (in addition to the authentication node of course).
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