Developer forum

Forum » Templates » Redirect after login

Redirect after login

Angel
Reply

Hi

 

I'm implementing a website where I have one login form, but where I need to access it from several pages (extranet login page, forum login page, etc.). Is there some way to indicate in the template that DW should return the user to the page, where he came from after login?

 

The main reason is the forum page, where the client don't want to have another login form. We should then redirect the user to the central login form and send the user back to the forum start page after login.

 

I could of course create several (hidden) login pages - each one with it's specific redirection, but could there be a better solution? Maybe some "if statement" or similar?

 


Replies

 
Reply
Angel wrote:

Hi

 

I'm implementing a website where I have one login form, but where I need to access it from several pages (extranet login page, forum login page, etc.). Is there some way to indicate in the template that DW should return the user to the page, where he came from after login?

 

The main reason is the forum page, where the client don't want to have another login form. We should then redirect the user to the central login form and send the user back to the forum start page after login.

 

I could of course create several (hidden) login pages - each one with it's specific redirection, but could there be a better solution? Maybe some "if statement" or similar?

 


 

I'm having the same question. Maybe send the refferer page id in a querystring and submit to this querystring parameter to get the right page? Looking forward to an answer.

 
Nicolai Høeg Pedersen
Reply

There is no standard support for this - but it is easily extenable:

 

Create a simple notification subscriber that listens to the extranet login. When a user logs in a parameter in the login form called RedirectToUrl can be used to do the redirect. Hope this helps.

 

 <Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.Standard.User.OnAfterLogin)> _
Public Class NotifcationSubscriberTest
 Inherits Extensibility.NotificationSubscriber
 Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Dynamicweb.Extensibility.NotificationArgs)
  'Lets get an instance of the arguments
  Dim arg As Dynamicweb.Notifications.Standard.User.OnAfterLoginArgs = CType(args, Dynamicweb.Notifications.Standard.User.OnAfterLoginArgs)
  If Not String.IsNullOrEmpty(Base.Request("RedirectToUrl")) Then
   HttpContext.Current.Response.Redirect(Base.Request("RedirectToUrl"))
  End If
 End Sub
End Class

 

 
Reply

You might also just embed the form in the page template, so you have the login form everywhere. All Dynamicweb needs to log you on is valid values in username and password in the request.

 

You must be logged in to post in the forum