abhijeet
  • Posts: 4
  • Joined: 15/03/2012
Hey I'm new to YAF!!!

In my website I have my own login & registration modules.And i'm not using ASP.net membership.
I want to integrate YAF into my website.
As far as I know YAF requires ASP.net membership,googled alot :?: ,but unable to figure out how to achieve my login & registraion for YAF???

Thanks in advance!!!


Abhijeet Gupta
www.addya.in 
abhijeet
  • Posts: 4
  • Joined: 15/03/2012
Solved my issue!!

I followed steps from:


YAF With Existing Website Running On asp.net 4.0 

And added following code into my sign up code:


private void CreateUser(String sApplicationName, String sUserName, String sPassword, String sEmail)
{

YafMembershipProvider mb = (YafMembershipProvider)System.Web.Security.Membership.Providers["YafMembershipProvider"];
int? forumUserID = 0;

if (!mb.ValidateUser(sUserName, sPassword))
{
MembershipCreateStatus status;
MembershipUser forumUser = mb.CreateUser(sUserName, sUserName, sUserName, "question", "answer", true, null, out status);

// create the user in the YAF DB as well as sync roles...
forumUserID = RoleMembershipHelper.CreateForumUser(forumUser, 1);

RoleMembershipHelper.SetupUserRoles(1, sUserName);
RoleMembershipHelper.AddUserToRole(sUserName, "Registered");

// create empty profile just so they have one
YafUserProfile userProfile = YafUserProfile.GetProfile(sUserName);
userProfile.Homepage = "fwd.com";

// setup their inital profile information
userProfile.Save();
}
else
{
DataTable results =(DataTable) YAF.Classes.Data.DB.UserFind(1, false, sUserName, sUserName, sUserName, null, null);
//DataTable results = YAF.Classes.Data.DB.UserFind(1, false, sUserName, sUserName);
if (results.Rows.Count > 0)
{
forumUserID = (int)results.Rows[0]["UserID"];
}
}

FormsAuthentication.SetAuthCookie(sUserName, false);
}
Abhijeet Gupta
www.addya.in 
ankit
  • Posts: 14
  • Joined: 18/01/2013
Hi,
I have the same problem, link of my topic is here:
http://forum.yetanotherf...th-existing-website.aspx 

I want to use YAF with scenario explained here:

--> I am using YAF as a forum and I have implemented it in my project in a sub-folder named "Forum" so all files and folder of folder "YetAnotherForum.NET" is included in that sub-folder and changes according to webconfig is also done.

--> So now I have not used membership control in my website and so if a user logged in to my website and he is clicking forum link then he must be able to access YAF without login and he does not have to login again at YAF and should be able to post topics because he has logged in to my existing website.

--> Is it possible to do it with the code you have provided here?
abhijeet
  • Posts: 4
  • Joined: 15/03/2012
yeah it works.

when a user logs in your website set the Auth cookies.

i.e. : FormsAuthentication.SetAuthCookie(sUserName, false);
Abhijeet Gupta
www.addya.in 
ankit
  • Posts: 14
  • Joined: 18/01/2013
Hi,
Thanks. And yes I am doing the same. After setting values in my session variables I am using you code i.e. FormsAuthentication.SetAuthCookie(sUserName, false); to set values for YAF and it working perfectly if I am operatin my website with VisualStudio but when I am publishing my website and trying to use it thorough localhost that thing does't work.

Can you help me out for this problem. Have you tried this after publish website to live url? Can you give me URL link for that website.

Thanks for reply.
sinachi
  • Posts: 3
  • Joined: 15/04/2013
when a user logs in your website set the Auth cookies.
SamsonAtYAF
  • Posts: 2
  • Joined: 19/09/2013
Question, I'm trying to do this right now .... But I am confused! Do you put that code in the LOGIN or REGISTER ACCOUNT section. Or in both.

I'm a bit confused now doing a CREATE on LOGIN would work.

Please let me know what I can do at LOGIN!

Second question, You dont seem to actually pass the password value to CREATEUSER. I'm also a bit confused by that?
abhijeet
  • Posts: 4
  • Joined: 15/03/2012
Hi Samson

I called CreateUser(.....) method ,in my User Registration Code.

And set the Authentication cookies for the user ;after registration of user so that he can use the forum straightaway,which is the last line i.e. : FormsAuthentication.SetAuthCookie(sUserName, false);

Put the above code in your login code after processing login credential.


Answer for your second question is: as we're not using the Login/Register module of YAF;I disabled the login and registration page of YAF;it was just the formality to pass password while creating User,hence I passed the sUserName for forum.
Abhijeet Gupta
www.addya.in 
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