login after period of inactivity

72 views
Skip to first unread message

Maurice Waka

unread,
May 5, 2020, 2:38:29 PM5/5/20
to web2py-users
I notice this message after a period of inactivity. See attached.
The problem is that on clicking on the login link on the app on pythonanywhere, I get an error: invalid view (default/user/load).
How can I resolve this?
Regards
Screenshot from 2020-05-05 21-31-58.png

Jim S

unread,
May 5, 2020, 4:09:07 PM5/5/20
to web2py-users
Can you show some code?

-Jim

Maurice Waka

unread,
May 6, 2020, 1:01:44 AM5/6/20
to web2py-users
I don't know what code I could show since the app is online, but in my routes.py:

from fileutils import abspath
from languages import read_possible_languages

possible_languages = read_possible_languages(abspath('applications', app))
# ----------------------------------------------------------------------------------------------------------------------
# NOTE! app - is an application based router's parameter with name of an application. E.g.'welcome'
# ----------------------------------------------------------------------------------------------------------------------

routers = {
    app: dict(
        default_language=possible_languages['default'][0],
        languages=[lang for lang in possible_languages if lang != 'default']
    )
}

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Px0b1zYX-Zg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/541b05b3-02b7-4bc8-8773-f093a41bc1ce%40googlegroups.com.

Maurice Waka

unread,
May 6, 2020, 1:11:55 AM5/6/20
to web2py-users
Actually, I want to customize the code to get better feedback, and after digging in I got this discussion

I just don't know where to exactly place this code, or get something better:
auth.messages.ajax_failed_authentication = DIV(H4(T('Your session has expired')),
T('Please '),
A(T('login'),
_href=auth.settings.login_url +
('?_next=' + urllib.quote(request.env.http_web2py_component_location))
if request.env.http_web2py_component_location else ''),
T(' again to view this content.'),
_class='not-authorized alert alert-block')


On Tue, May 5, 2020 at 11:09 PM Jim S <ato....@gmail.com> wrote:
--

Jim S

unread,
May 6, 2020, 8:58:01 AM5/6/20
to web2py-users
You said you notice this message after a period of inactivity, but you also say this message comes up after clicking login.  What is telling you that this is happening after a period of inactivity?

I was hoping to see what you have for default/user/load (which you referenced above) - load is not a built-in function in default/user that I'm aware of. 

Here is the normal default/user signature:


def user():
   
"""
    exposes:
    http://..../[app]/default/user/login
    http://..../[app]/default/user/logout
    http://..../[app]/default/user/register
    http://..../[app]/default/user/profile
    http://..../[app]/default/user/retrieve_password
    http://..../[app]/default/user/change_password
    use @auth.requires_login()
        @auth.requires_membership('group name')
        @auth.requires_permission('read','table name',record_id)
    to decorate functions that need access control
    """

So I was thinking you had put something custom in there.

Are you able to force it to happen by setting your auth.settings.expiration to a low number of seconds?

-Jim
To unsubscribe from this group and all its topics, send an email to web...@googlegroups.com.

Maurice Waka

unread,
May 6, 2020, 6:58:09 PM5/6/20
to web2py-users
After clicking the login, that's when the error comes in.
No I haven't set the timer. I left the same time length in default.
Kind regards

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/badaa3f7-1281-412d-81a0-6b053adb8040%40googlegroups.com.

Jim Steil

unread,
May 6, 2020, 9:08:37 PM5/6/20
to web...@googlegroups.com
Can you share the code for the user function in default.py? 

How do you know that the session timed out?

Jim


Maurice Waka

unread,
May 8, 2020, 3:38:35 AM5/8/20
to web2py-users
I did not have the code for timeout function(wish I could do that)
But going back to my error issue, I solved it by:
model:

auth.settings.login_next = URL('default','user',args='login', extension=False)

default/user:
auth.messages.ajax_failed_authentication = DIV(H4(T('Your session has expired')),
                            T('Please '),
                            A(T('login'),
                              _href=auth.settings.login_url +
                                    ('?_next=' + urllib.quote(request.env.http_web2py_component_location))
                              if request.env.http_web2py_component_location else ''),
                            T(' again to view this content.'),
                            _class='not-authorized alert alert-block')
Reply all
Reply to author
Forward
0 new messages