delete and logout user

35 views
Skip to first unread message

Alex Glaros

unread,
Nov 24, 2015, 11:44:24 AM11/24/15
to web2py-users
If a user deletes their account, my controller deletes their db.auth_user record but their login session is still active.  If I try to auth.logout() then, I get integrity restraint error.  If I log them out first, I don't automatically have their user_id to delete the records with.

Is there a simple way to handle this?

thanks,

Alex Glaros

Anthony

unread,
Nov 24, 2015, 11:55:50 AM11/24/15
to web2py-users
Sure, grab the ID first, then logout, then delete.

Leonel Câmara

unread,
Nov 24, 2015, 12:28:13 PM11/24/15
to web2py-users
Anthony shouldn't Auth.profile do that by default?

Anthony

unread,
Nov 24, 2015, 12:52:12 PM11/24/15
to web...@googlegroups.com
On Tuesday, November 24, 2015 at 12:28:13 PM UTC-5, Leonel Câmara wrote:
Anthony shouldn't Auth.profile do that by default?

Yes. I assumed he was using some custom user account deletion workflow.

Alex, if you set auth.settings.allow_delete_accounts=True, you can let users delete their accounts via the auth.profile() action, and all of this is handled automatically.

Anthony

Alex Glaros

unread,
Nov 24, 2015, 2:05:35 PM11/24/15
to web2py-users
Anthony,

am using custom deletion workflow.  

Where is best place to store the user_id so logout doesn't erase it?  session?  temp table?

thanks

Alex

Anthony

unread,
Nov 24, 2015, 3:21:19 PM11/24/15
to web2py-users
Presumably the logout and delete are happening in the same request, so just put the id in a variable. Hard to say exactly how you should handle it without seeing your code.

Alex Glaros

unread,
Nov 24, 2015, 5:33:26 PM11/24/15
to web2py-users
thanks guys, good insight as always
Reply all
Reply to author
Forward
0 new messages