Skip to content

Commit

Permalink
[AdminTL#83] Login: add third-party when subscribe
Browse files Browse the repository at this point in the history
- redirect to profile when subscribe and auto-connect
  • Loading branch information
mathben committed Mar 31, 2018
1 parent a005f80 commit 86e308d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/web/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions src/web/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 28 additions & 0 deletions src/web/partials/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ <h3 class="omb_authTitle"><b>Connexion</b> ou <a href="#" ng-click="show_login=f
{% end %}
<h3 class="omb_authTitle"><a href="#" ng-click="show_login=true;" style="text-decoration: underline">Connexion</a> ou <b>Inscription</b></h3>

<div class="row omb_row-sm-offset-3 omb_socialButtons">
<div class="col-xs-4 col-sm-2">
<a href="/cmd/auth/facebook" class="btn btn-lg btn-block omb_btn-facebook">
<i class="fa fa-facebook visible-sm"></i>
<span class="hidden-sm">Facebook</span>
</a>
</div>
<div class="col-xs-4 col-sm-2">
<a href="/cmd/auth/google" class="btn btn-lg btn-block omb_btn-google">
<i class="fa fa-google-plus visible-sm"></i>
<span class="hidden-sm">Google+</span>
</a>
</div>
<div class="col-xs-4 col-sm-2">
<a href="/cmd/auth/twitter" class="btn btn-lg btn-block omb_btn-twitter">
<i class="fa fa-twitter visible-sm"></i>
<span class="hidden-sm">Twitter</span>
</a>
</div>
</div>

<div class="row omb_row-sm-offset-3 omb_loginOr">
<div class="col-xs-12 col-sm-6">
<hr class="omb_hrOr">
<span class="omb_spanOr">ou</span>
</div>
</div>

<div class="row omb_row-sm-offset-3">
<div class="col-xs-12 col-sm-6">
<form name="signUpForm" class="omb_signUpForm" action="" autocomplete="off" method="POST">
Expand Down

0 comments on commit 86e308d

Please sign in to comment.