Developer forum

Forum » Development » UserAcceslogin Notification?

UserAcceslogin Notification?


Reply

Is there a way to get a notification when a user logs in.

 

I need todo some stuff when a user logs in.


Replies

 
Reply

Hi Jais

 

There is a notification called: "Dynamicweb.Notifications.Standard.User.OnAfterLogin"

 

here is a snippet for you:

 

using System;
using Dynamicweb;
using System.Web;
using Dynamicweb.Frontend;
using Dynamicweb.Extensibility;

namespace DoYouNotice {
    [Subscribe(Dynamicweb.Notifications.Standard.User.OnAfterLogin)]
    public class UserNotification : NotificationSubscriber {
        public override void OnNotify( string notification, object[] args ) {
            base.OnNotify(notification, args);

            Dynamicweb.Notifications.Standard.User.OnAfterLoginArgs myUser = args[0] as Dynamicweb.Notifications.Standard.User.OnAfterLoginArgs;

            Base.w(myUser.User.Name);
        }
    }
}

 

 

this is for the frontend/extranet, im not sure about what happens if the user logs into the Admin.

 

/Kenneth

 

 
Reply

 "Dynamicweb.Notifications.Standard.User.OnAfterLogin"

 

doesent seem to exsist, i only see Page?

 
Reply
jed@dkis.dk wrote:

 "Dynamicweb.Notifications.Standard.User.OnAfterLogin"

 

doesent seem to exsist, i only see Page?


Wupps, it helps to update from v. 242 to 272 :) Thats probally why i couldent find it. Thanks :)

 
Reply

Just on a side node, this event accures before login and 2 times after login :) but made a work around with a try catch and some time stamping :)

 
Reply

It fires three times? Better look into that:)

 
Reply
Sorensen wrote:

It fires three times? Better look into that:)


yes please :)

 

while ur there can u make an new event OnEditSubmit like when a user has edited its profile. It would be great. as i need to code some stuff to send an email etc. after a profile is edit'd. (in the meantime i guess i have to make it work with some query testing n stuff) :)

 
Nicolai Høeg Pedersen
Reply

Hi Jais

 

looked into it - found an error causing the login to be called twice in some situations.

 

I've made a fix which will make it to production during the fall.

 

You must be logged in to post in the forum