Re: Best way to check for first Login



As I had no reaponses I guess I was either on the wrong tracks totally, or
no one had a work around.

In the end, I added extra properties to the users profile and checked those
upon logging in (i.e. I didn't use the onAuthenticate event at all)

JJ

"JJ" <abc@xxxxxxx> wrote in message
news:OzjXfAi3GHA.2228@xxxxxxxxxxxxxxxxxxxxxxx
I am comparing the 'lastloggedin' and 'createddate' fields of the
membership table to see if this is the first time the user has logged in.
(if they are within 1 second on each other I presume this is the first
login).

I have worked out that I can't check for this in the 'onLoggedIn' event,
as this is after the 'lastloggedin' field is updated. So, I am trying to
do the check in the 'onAuthenticate' event.

However, when I add this handler I stop the authentication taking place.
How do I let authentication take place normally whilst still running my
extra code?
Or, is there another way to check for first login?


JJ

i.e.:
protected void OnAuthenticate(object sender, AuthenticateEventArgs e)

{


string thisUsername =
((System.Web.UI.WebControls.Login)(sender)).UserName;

DateTime CreatedDateTime = Membership.GetUser(thisUsername).CreationDate;

DateTime LastLoggedInDateTime =
Membership.GetUser(thisUsername).LastLoginDate;

System.TimeSpan TimeDiff = LastLoggedInDateTime.Subtract(CreatedDateTime);

//Probably only need 2 seconds max

if (TimeDiff.TotalSeconds < 2)

{

//this is first login

FirstLogin = true;

}

}




.



Relevant Pages

  • Problem carrying authentication forward to other pages after login
    ... first login via a login web page. ... capture the authentication and pass it on to subsequent ... I am having a problem carrying forward the authentication ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: SSH Password Authentication
    ... > The authentication method is with a password. ... After the first login, I ... > never was asked again for the password on the UNIX Backup Server. ...
    (comp.security.ssh)