Developer forum
E-mail notifications
Reset session on profile change?
If a extranet user submits changes to a profile, the dw session including the extranet groups which the user are member of, are not reset.
It means that if a user makes changes to a profile that will allows the user to see a "hidden" pages - but visible to a certain extranet group - the user has to log out and login again, before the pages is visible.
Anyone with a workarround?
/Morten
Replies
Subscribe to the Modules.UserManagement.Notifications.UserSaved notification and login the user again:
<Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserSaved)> _
Public Class NotificationSubscriber1
Inherits NotificationSubscriber
'For notifications passing an object inheriting Dynamicweb.Extensibility.NotificationArgs
Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Dynamicweb.Extensibility.NotificationArgs)
'Make sure we are in the frontend...
If Not PageView.Current Is Nothing Then
Dim myArgs As Dynamicweb.Modules.UserManagement.UserNotificationArgs = DirectCast(args, Dynamicweb.Modules.UserManagement.UserNotificationArgs)
Dim ex As New Security
ex.ExtranetLogin(myArgs.Subject.UserName, myArgs.Subject.Password)
End If
End Sub
End Class
using System;
using System.Web;
using Dynamicweb;
using Dynamicweb.Extensibility;
using Dynamicweb.Frontend;
namespace CustomModules.CustomModules
{
[Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserSaved)]
public class UserManagementBugFix : NotificationSubscriber
{
public override void OnNotify(string notification, NotificationArgs args)
{
if (PageView.Current() == null) return;
var una = args as Dynamicweb.Modules.UserManagement.UserNotificationArgs;
if (una == null) return;
// We only need to fix the bugs once, so lets check if we have already fixed it
// - User managent calls User.Save multiple times on create/edit profile
if (HttpContext.Current.Items.Contains("UserManagementBugFix")) return;
// Edit profile: Update session after edit
// - How the hell did you miss that one DW? :)
if (Base.ChkString(Base.Request("Action")).Equals("Edit"))
new Security().ExtranetLogin(una.Subject.UserName, una.Subject.Password);
// Create profile: Update ValidFrom to ensure that the autologin feature works
// - Problem with Dates.DWNow precision when used in Security.ExtranetLogin - user not active yet!?
if (una.Subject.ValidFrom.AddMinutes(1) > DateTime.Now)
una.Subject.ValidFrom = DateTime.Now.AddMinutes(-1);
HttpContext.Current.Items.Add("UserManagementBugFix", true);
}
}
}
@mbe: Comments in code = he he ;)
Is this something we can expect to see standard in Dynamicweb in a future service release?
BR,
Nuno
You must be logged in to post in the forum