becometechmad
  • Posts: 1
  • Joined: 26/05/2014
Dear Friends,
I just started digging into Yet another forum. I have come across following scenario. I would appreciate if anyone can help me towards the right approach.
I have 2 sites web.mysite.com and forum.mysite.com. Both of them are installed in different web server and are running successfully with their own user management and login mechanism.
web.mysite.com
======================
This is created using MVC3 and has its own authentication mechanism with SQL server database
Login==> Login mechanism leveraging Entity framework with simple DB call to validate user’s credential and creating forms authentication cookie instead.
User Registration==> Simple Db call with Entity framework to create a user in database.

Note: No where I am using ASP.Net membership provider.

forum.mysite.com
======================
Installed the latest version from yetanotherforum.com and configured. As per my knowledge it leverages “yafmembership provider” for authentication and user management.

My Requirement==>
1. I would like to have a single system for authentication and user management. Currently above 2 sites have their own user management and data persistence mechanisim.
2. If user already logged-in into web.mysite.com then he would automatically logged- in into forum.mysite.com and vise versa for logged-out.
3. User registration, profile update , login will be done from common page for both the site.
4. I would like to maintain single database for user management for both the system









Sponsor
ransems
  • Posts: 11
  • Joined: 16/07/2014
I would think this is a common and typical request, as I just started using YAF and already want this! Anyone?
bbobb
  • Posts: 1558
  • Joined: 21/10/2008
The most simple way would be to rewrite web.mysite.com code to use YAF providers.
ransems
  • Posts: 11
  • Joined: 16/07/2014
Any code samples on how to do this? Any walkthroughs for that?
ransems
  • Posts: 11
  • Joined: 16/07/2014
Someone must have done this?
tsb6670
  • Posts: 5
  • Joined: 13/08/2014
I'm still working on this - but to help move this topic along, I'll post what progress I have made so far.

(1) edit web.config and set the default loginUrl to your website login page (e.g. Login.aspx)
<authentication mode="Forms">
  <forms name=".YAFNET_Authentication" loginUrl="~/Login.aspx" protection="All" timeout="43200" cookieless="UseCookies"/>
</authentication>


(2) create a default login page (e.g. Login.aspx) and use the standard ASP.NET asp:Login control
<asp:Login ID="usrLogin" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt">
    <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
</asp:Login>


(3) in your Page_Load method for any page that requires authenticated users, redirect the request to your new Login.aspx page. This login page will log the user into the entire site including the YAF forum.
// check for authentication
if (!Request.IsAuthenticated)
{
    FormsAuthentication.RedirectToLoginPage();
    return;
}


At this stage, the changes above work to authenticate users. I'm still working on further integration using the YAF controls (pages/login.ascx) - which isn't working for me yet.

Tracy.

tsb6670
  • Posts: 5
  • Joined: 13/08/2014
Following up from my previous post - to integrate YAF into an existing site and share the YAF authentication and membership providers, you will also need to create a new account page so new users don't have to navigate into the forum to create an account. To do this, create a new page such as NewAccount.aspx and drag and drop the ASP:CreateUserWizard control into your new page (standard ASP control).

Using the CreateUserWizard, add an OnCreatedUser event. This event is where you will store the created user default role. The default role for YAF members is "Registered" and the administration role is called "Administrators". If you don't assign a role to your new user accounts, YAF will respond with an error when you try to use that account.

protected void wizardCreateUser_CreatedUser(object sender, EventArgs e)
{
    String UserName = wizardCreateUser.UserName;
    if ((UserName != String.Empty) && (UserName.Length > 0))
    {
        Roles.AddUserToRole(wizardCreateUser.UserName, "Registered");
    }
    return;
}


Next, you'll want to create an OnContinueButtonClick event. Using this event, you'll redirect the user to an appropriate page such as the homepage.

protected void wizardCreateUser_ContinueButtonClick(object sender, EventArgs e)
{
	Response.Redirect("~/Default.aspx");
	return;
}


Note that the asp CreateUserWizard handles everything else using the providers you have defined in your web.conf file. For integration, you'll be using the YAF providers already discussed in my previous post.

Hope this helps.
Tracy.


tsb6670
  • Posts: 5
  • Joined: 13/08/2014
Follow up on YAF membership roles - in your aspx code for non-forum pages, you can use the asp:LoginView control to filter content based on the YAF member role; for example, content for "Registered" members versus content for "Administrators" members.

<asp:LoginView ID="pageLoginView" runat="server">
	<RoleGroups>
		<asp:RoleGroup Roles="Registered">
			<ContentTemplate>
				<!-- Content for YAF Registered members (default role) -->
				<p>I AM A MEMBER</p>
			</ContentTemplate>
		</asp:RoleGroup>
		
		<asp:RoleGroup Roles="Administrators">
			<ContentTemplate>
				<!-- Content for YAF Administrators members (admin role) -->
				<p>I AM AN ADMINISTRATOR</p>
			</ContentTemplate>
		</asp:RoleGroup>
	</RoleGroups>
</asp:LoginView>

In the C# code behind, to find controls that you've placed in these RoleGroup containers, you'll need to using the asp:LoginView FindControl() method. Otherwise your code will not compile. The code below is an example of how to access a control using C#. The xml above doesn't have any controls in the RoleGroup containers.

TextBox myText= pageLoginView.FindControl("MyTextBoxID") as TextBox;


Cheers,
Tracy.
sundramca
  • Posts: 1
  • Joined: 09/10/2017
any one completed this recently can share their experience next steps
paultg
  • Posts: 3
  • Joined: 08/07/2018
I'm also just getting to grips with YAF, as we've recently started using it as a staff forum. It'd be great if we could have our staff log in to our existing aspx portal page and have the system create a yaf login for them. In my case, the forum is a sub-folder application of the main portal.

If anyone's done this and has a simplified version that an amateur coder could use, I'm all ears, and potentially buying the beers.
tha_watcha
  • Posts: 4063
  • Joined: 06/03/2010
It is possible. What authentication system are you using?
UserPostedImage
paultg
  • Posts: 3
  • Joined: 08/07/2018
Originally Posted by: tha_watcha

It is possible. What authentication system are you using?



Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).
tha_watcha
  • Posts: 4063
  • Joined: 06/03/2010
Originally Posted by: paultg

Originally Posted by: tha_watcha

It is possible. What authentication system are you using?



Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).


And the DB is a custom db or did you mean the Forum database?


UserPostedImage
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