From 86e308da9183c64d5f4f73b7393cd3a965c9affc Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 31 Mar 2018 15:57:06 -0400 Subject: [PATCH] [#83] Login: add third-party when subscribe - redirect to profile when subscribe and auto-connect --- src/web/base_handler.py | 2 +- src/web/handlers.py | 13 +++++++++++-- src/web/partials/login.html | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/web/base_handler.py b/src/web/base_handler.py index 2911405b..1694bbf6 100644 --- a/src/web/base_handler.py +++ b/src/web/base_handler.py @@ -60,7 +60,7 @@ def get_current_user(self): return # trim private data - data = json.loads(user_cookie) + data = json.loads(user_cookie.decode("utf-8")) if type(data) is dict: user_id = data.get("user_id") return self._db.get_user(id_type="user", user_id=user_id) diff --git a/src/web/handlers.py b/src/web/handlers.py index 39a5fc5f..cd69bbb3 100644 --- a/src/web/handlers.py +++ b/src/web/handlers.py @@ -138,8 +138,17 @@ def post(self): name = self.get_argument("name", default=None) postal_code = self.get_argument("postal_code", default=None) - if self._db.create_user(username, name=name, email=email, password=password, postal_code=postal_code): - self.redirect("/login") + # TODO uncomment when need to validate email + # if self._db.create_user(username, name=name, email=email, password=password, postal_code=postal_code): + # self.redirect("/login") + # return + # else: + # self.redirect("/login?invalid=signup") + # return + # TODO comment when need to validate email + user = self._db.create_user(username, name=name, email=email, password=password, postal_code=postal_code) + if user: + self.give_cookie(user.get("user_id")) return else: self.redirect("/login?invalid=signup") diff --git a/src/web/partials/login.html b/src/web/partials/login.html index c24e96f3..186a24f2 100644 --- a/src/web/partials/login.html +++ b/src/web/partials/login.html @@ -105,6 +105,34 @@

Connexion ou Connexion ou Inscription

+
+ + + +
+ +
+
+
+ ou +
+
+