Welcome Guest! To enable all features please
Login or Register.
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
I would think this is a common and typical request, as I just started using YAF and already want this! Anyone?
The most simple way would be to rewrite web.mysite.com code to use YAF providers.
Any code samples on how to do this? Any walkthroughs for that?
Someone must have done this?
Edited by user
2014-08-05T15:10:31Z
|
Reason: Reread first post
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.
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.
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.
any one completed this recently can share their experience next steps
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.
It is possible. What authentication system are you using?
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).
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?
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.
Important Information:
The YAF.NET Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close