logout redirect

28 views
Skip to first unread message

dbv

unread,
Dec 13, 2012, 12:58:20 PM12/13/12
to cork-d...@googlegroups.com
Testing the logout function with this code:

# server.py
@bottle.post('/login')
def login():
    """Authenticate users"""
    email_addr = post_get('email')
    password = post_get('password')
    username = post_get('username')
    aaa.login(username, password, success_redirect='/dash', fail_redirect='/login')

@bottle.route('/logout')
def logout():
    aaa.logout(success_redirect='/', fail_redirect='/login')

# dash.html
<form>
    <button type="submit" class="btn"><a href="/logout">Logout</a></button>
</form>

* re-directs successfully to /dash, POST 303, but 
* fails to re-direct to '/' but instead re-directs to '/login', POST 303

Did I miss something?

Federico Ceratto

unread,
Dec 13, 2012, 1:11:37 PM12/13/12
to cork-d...@googlegroups.com
On Thu, Dec 13, 2012 at 5:58 PM, dbv <dinesh...@hotmail.com> wrote:

> @bottle.route('/logout')
> def logout():
> aaa.logout(success_redirect='/', fail_redirect='/login')
>
> # dash.html
> <form>
> <button type="submit" class="btn"><a href="/logout">Logout</a></button>
> </form>
>
> * re-directs successfully to /dash, POST 303, but
> * fails to re-direct to '/' but instead re-directs to '/login', POST 303

Sounds like the logout is failing. You can remove the redirects and
print its output as a test.
Check if the cookie is being set/removed as expected from the browser.

Bye,
--
Federico

dbv

unread,
Dec 13, 2012, 2:44:51 PM12/13/12
to cork-d...@googlegroups.com
debugging in cork.py:
cookie is set at /login
session cookie is removed at /logout
fails in def logout() at line 222
    bottle.redirect(success_redirect) 
when success_redirect='/'.  
tried with success_redirect='/somethingelse' but it still fails.
in each case it drops to the except clause.

that is a bit weird ... can't see what the problem is.
Reply all
Reply to author
Forward
0 new messages