librelist archives

« back to archive

Handling the 'remember me' login (for logging)

Handling the 'remember me' login (for logging)

From:
Wells Oliver
Date:
2014-10-11 @ 02:06
Good evening-- my login function puts a record in the DB w/ user,
timestamp, and IP address.

Can I handle the 'remember me' login when using login_user(....,
remember=True) as to also log this record?

Thanks.

-- 
Wells Oliver
wellsoliver@gmail.com

Re: [flask] Handling the 'remember me' login (for logging)

From:
David Nieder
Date:
2014-10-12 @ 08:40
Good morning.
I assume you are using the flask-login extension.
Flask-Login sends a signal when a user is logged in. You could subscribe 
to than signal and maybe check flask.ext.login.login_fresh() if you want 
to know if the user actually logged in or was authenticated via the 
remember_me cookie.

Have a nice day


http://flask-login.readthedocs.org/en/latest/#signals

On 11.10.2014 04:06, Wells Oliver wrote:
> Good evening-- my login function puts a record in the DB w/ user,
> timestamp, and IP address.
>
> Can I handle the 'remember me' login when using login_user(....,
> remember=True) as to also log this record?
>
> Thanks.
>

Re: [flask] Handling the 'remember me' login (for logging)

From:
Wells Oliver
Date:
2014-10-12 @ 18:25
I am. It seems like the user_logged_in signal is only fired for actual
logins, not for cookie-based remembered logins. Am I correct?

On Sun, Oct 12, 2014 at 1:40 AM, David Nieder <davidnieder@gmx.de> wrote:

> Good morning.
> I assume you are using the flask-login extension.
> Flask-Login sends a signal when a user is logged in. You could subscribe
> to than signal and maybe check flask.ext.login.login_fresh() if you want
> to know if the user actually logged in or was authenticated via the
> remember_me cookie.
>
> Have a nice day
>
>
> http://flask-login.readthedocs.org/en/latest/#signals
>
> On 11.10.2014 04:06, Wells Oliver wrote:
> > Good evening-- my login function puts a record in the DB w/ user,
> > timestamp, and IP address.
> >
> > Can I handle the 'remember me' login when using login_user(....,
> > remember=True) as to also log this record?
> >
> > Thanks.
> >
>
>


-- 
Wells Oliver
wellsoliver@gmail.com

Re: [flask] Handling the 'remember me' login (for logging)

From:
David Nieder
Date:
2014-10-13 @ 10:03
On 12.10.2014 20:25, Wells Oliver wrote:
> I am. It seems like the user_logged_in signal is only fired for actual
> logins, not for cookie-based remembered logins. Am I correct?

Yes, you are.
I just looked at the code and there is an user_loaded_from_cookie signal 
which should do the trick. I don't know why it is not in the docs.

Re: [flask] Handling the 'remember me' login (for logging)

From:
Wells Oliver
Date:
2014-10-13 @ 16:34
Perfect! That works. We should get that added to the documentation it's
very useful.

On Mon, Oct 13, 2014 at 3:03 AM, David Nieder <davidnieder@gmx.de> wrote:

> On 12.10.2014 20:25, Wells Oliver wrote:
> > I am. It seems like the user_logged_in signal is only fired for actual
> > logins, not for cookie-based remembered logins. Am I correct?
>
> Yes, you are.
> I just looked at the code and there is an user_loaded_from_cookie signal
> which should do the trick. I don't know why it is not in the docs.
>
>


-- 
Wells Oliver
wellsoliver@gmail.com