Default page after login?

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
9/9/2008 7:41:49 AM
Gravatar
Total Posts 92

Default page after login?

I finally just launched our new and improved company portal using version 2.2.6.8 and was wondering if a certain behavior can be used.

I have three tabs.

  1. Home
  2. Employees
  3. Visitors

Users who haven't logged in only see Home.

Users in the Employee group see Home, Employees and Visitors.

Users in the Visitors group see Home and Visitors.

My question is after the user logs in, is there a way to make it jump to the Employees page or Visitors Page?   A user default page feature would be nice.

I've experimented with hiding the Home page, but after logging in the tab disappears but it still shows the home page until the user clicks one of the available tabs.

The reason is that once people log in they are looking at the same introductory Home page, and many users never saw the tabs and are calling the helpdesk all the time asking where the content is.  The employees will figure it out sooner or later, but once we start inviting clients in to pick up files and become involved in the forums I don't want to cause any more confusion or load on the helpdesk phone.

Any ideas?

9/9/2008 7:51:19 AM
Gravatar
Total Posts 18439

Re: Default page after login?

You could potentially implement your own custom UserSignInEventHandler and then do a hard redirect according to your own logic.

http://www.mojoportal.com/user-sign-in-event-handlers.aspx

Hope it helps,

Joe

9/9/2008 7:57:10 AM
Gravatar
Total Posts 92

Re: Default page after login?

Damn that was fast!  Sounds perfect.  I'll get right on that.

I was forced to launch the portal on a windows 2000 server (the only server version I had in the office)  Mono is still too flakey to run the portal reliably and at a comfortable speed.  I compromised though by running apache instead of IIS so I'd feel more at home.  ;)

I'm busy training the departments managers on it's capabilities and how to add content to their assigned areas. 

You're making me look good!  Thanks Joe!

9/18/2008 9:10:23 AM
Gravatar
Total Posts 92

Re: Default page after login?

I just compiled the do-nothing sign in handler and got it working.   Now I have to figure out the logic.

I need to make it do the following.

1. If the person logging in is a member of the 'employees' group then redirect to ~/employees.aspx

2. If the person loggin in is a member of the 'visitors' group then redirect to ~/visitors.aspx

3. Otherwise load the default ~/home.aspx

I tried messing around with WebUtils.SetupRedirect but that won't work because it isn't a UI.Control.

Any hints on how to accomplish this logic?

 

9/18/2008 9:15:24 AM
Gravatar
Total Posts 18439

Re: Default page after login?

if(WebUser.IsInRole("employees"))
{
HttpContext.Current.Response.Redirect("/Employees.aspx");
}

Hope it helps,

Joe

 

9/18/2008 10:38:53 AM
Gravatar
Total Posts 92

Re: Default page after login?

That helped a lot getting it compiled.

I put the config file at \Setup\ProviderConfig\usersigninhandlers\001_clUserSignInHandlerProvider.config

<?xml version="1.0" encoding="utf-8" ?>
<UserSignInHandlers>
<providers>

<add name="clUserSignInHandlerProvider"
type="mojoPortal.Business.WebHelpers.UserSignInHandlers.clUserSignInHandlerProvider, clUserSignInHandlerProvider"
description="clUserSignInHandlerProvider" />

</providers>
</UserSignInHandlers>

I compiled the followiing to the assembly clUserSignInHandlerProvider.dll and copied it to \bin

using System;
using System.Configuration.Provider;
using System.Collections.Generic;
using System.Text;
using System.Web;
using log4net;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;
using mojoPortal.Business.WebHelpers.UserSignInHandlers;
using mojoPortal.Web.Framework;

namespace mojoPortal.Business.WebHelpers.UserSignInHandlers
{
public class clUserSignInHandlerProvider : UserSignInHandlerProvider
{
private static readonly ILog log = LogManager.GetLogger(typeof(clUserSignInHandlerProvider));

public clUserSignInHandlerProvider()
{
}

public override void UserSignInEventHandler(object sender, UserSignInEventArgs e)
{
if (e == null)
{
return;
}

if (e.SiteUser == null)
{
return;
}

if (WebUser.IsInRole("employees"))
{
HttpContext.Current.Response.Redirect("/employees.aspx");
log.Debug("Redirected user " + e.SiteUser.Email + " to employees.aspx");
return;
}

if (WebUser.IsInRole("visitors"))
{
HttpContext.Current.Response.Redirect("/visitors.aspx");
log.Debug("Redirected user " + e.SiteUser.Email + " to visitors.aspx");
return;
}

HttpContext.Current.Response.Redirect("/home.aspx");
log.Debug("Redirected user " + e.SiteUser.Email + " to home.aspx");
}
}
}

In the logs it doesn't show anything.   If I replace the 000_placeholder.config file it shows the DoNothing login handler sample.

I'm sure I've made a stupid dumb mistake, but where is it?  I earlier on changed the namespace (and config file to match) and it didn't work either...

Sorry for the long post!

 

9/18/2008 11:18:35 AM
Gravatar
Total Posts 18439

Re: Default page after login?

Set a break point and step through the code to find out whats really happening.

 

 

  

9/18/2008 11:19:30 AM
Gravatar
Total Posts 18439

Re: Default page after login?

Possibly WebUser.IsInRole won't work there because the role cookie may not be set yet. You may have to implement a different way to find out if th euser is in a role.

9/18/2008 11:41:00 AM
Gravatar
Total Posts 92

Re: Default page after login?

HttpContext.Current.Request.IsAuthenticated is always false at this point so WebUser.IsInRole won't work.

I'll find an alternate way...

You must sign in to post in the forums. This thread is closed to new posts.