diff --git a/src/web/base_handler.py b/src/web/base_handler.py index 956e89e4..72753a4b 100644 --- a/src/web/base_handler.py +++ b/src/web/base_handler.py @@ -82,6 +82,10 @@ def give_cookie(self, user_id, twitter_access_token=None, facebook_access_token= } serialize_data = json.dumps(data) self.set_secure_cookie("user", serialize_data) - self.redirect("/") + self.redirect("/profile") else: print("User doesn't have an id.", file=sys.stderr) + # Bad Request + self.set_status(400) + self.send_error(400) + raise tornado.web.Finish() diff --git a/src/web/handlers.py b/src/web/handlers.py index 53d05581..b3259fdb 100644 --- a/src/web/handlers.py +++ b/src/web/handlers.py @@ -75,7 +75,7 @@ class LoginHandler(base_handler.BaseHandler): @tornado.web.asynchronous def get(self): if self.get_current_user(): - self.redirect("/") + self.redirect("/profile") return self.render('login.html', **self._global_arg) @@ -83,7 +83,8 @@ def get(self): @tornado.web.asynchronous def post(self): if self._global_arg["disable_login"]: - self.redirect("/login?invalid=disable_login") + self.redirect("/") + return if self.get_current_user(): print("Need to logout before login or sign up from %s" % self.request.remote_ip, file=sys.stderr) @@ -119,6 +120,7 @@ def post(self): # If user is found, give him a secure cookie based on his user id if user: self.give_cookie(user.get("user_id")) + return else: print("Invalid email/password combination from %s" % self.request.remote_ip, file=sys.stderr) self.redirect("/login?invalid=login") @@ -168,7 +170,7 @@ def get(self): # If user is found, give him a secure cookie based on his user_id and Google access_token if user: self.give_cookie(user.get("user_id"), google_access_token=access_token) - + return # Sign up else: name = google_user["name"] @@ -186,6 +188,7 @@ def get(self): if user: self.give_cookie(user.get("user_id"), google_access_token=access_token) + return else: self.redirect("/login?invalid=google") return @@ -230,7 +233,7 @@ def get(self): # If user is found, give him a secure cookie based on his user_id and Facebook access_token if user: self.give_cookie(user.get("user_id"), facebook_access_token=access_token) - + return # Sign up else: name = facebook_user["name"] @@ -247,6 +250,7 @@ def get(self): if user: self.give_cookie(user.get("user_id"), facebook_access_token=access_token) + return else: self.redirect("/login?invalid=facebook") return @@ -287,7 +291,7 @@ def get(self): # If user is found, give him a secure cookie based on his user_id and Twitter access_token if user: self.give_cookie(user.get("user_id"), twitter_access_token=access_token) - + return # Sign up else: # nickname = twitter_user["screen_name"] @@ -306,6 +310,7 @@ def get(self): if user: self.give_cookie(user.get("user_id"), twitter_access_token=access_token) + return else: self.redirect("/login?invalid=twitter") return diff --git a/src/web/resources/js/tl_module/login_ctrl/login_ctrl.js b/src/web/resources/js/tl_module/login_ctrl/login_ctrl.js index f41a2176..50cc9b1c 100644 --- a/src/web/resources/js/tl_module/login_ctrl/login_ctrl.js +++ b/src/web/resources/js/tl_module/login_ctrl/login_ctrl.js @@ -1,6 +1,6 @@ // Formulaire de Traitre-Lame -characterApp.controller("login_ctrl", ['$scope', '$routeParams', function ($scope, $routeParams) { - $scope.show_login = true; +characterApp.controller("login_ctrl", ["$scope", "$routeParams", "$window", function ($scope, $routeParams, $window) { + $scope.show_login = !($window.location.search.indexOf("?subscribe") >= 0); $scope.invalid_login = false; $scope.log_facebook = function (e) { @@ -60,7 +60,6 @@ characterApp.directive('fieldMatch', function () { function validate(value) { var isValid = scope.$eval(attr.fieldMatch) == value; ngModel.$setValidity('fieldMatch', isValid); - console.log(isValid); return isValid ? value : undefined; } }