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 @@