From bfffc315ee81a8c65edef744219958349dea3c6e Mon Sep 17 00:00:00 2001 From: Luan Date: Tue, 17 Dec 2013 15:35:24 -0200 Subject: [PATCH] Creating session attribute if it doesn't exists - updates #104 --- src/proxy/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) diff --git a/src/proxy/models.py b/src/proxy/models.py index 8b32773..f81d07d 100644 --- a/src/proxy/models.py +++ b/src/proxy/models.py @@ -162,3 +162,16 @@ def change_session_attribute_email(sender, instance, **kwargs): cursor.execute(("UPDATE session_attribute SET value=%s " "WHERE name='name' AND sid=%s"), [instance.get_full_name(), instance.username]) + + cursor.execute(("INSERT INTO session_attribute " + "(sid, authenticated, name, value) " + "SELECT %s, '1', 'email', %s WHERE NOT EXISTS " + "(SELECT 1 FROM session_attribute WHERE sid=%s)"), + [instance.username, instance.email, instance.username]) + + cursor.execute(("INSERT INTO session_attribute " + "(sid, authenticated, name, value) " + "SELECT %s, '1', 'name', %s WHERE NOT EXISTS " + "(SELECT 1 FROM session_attribute WHERE sid=%s)"), + [instance.username, instance.get_full_name(), + instance.username]) -- libgit2 0.21.2