git.fiddlerwoaroof.com
Browse code

Fixed a redirect loop

User.py didn't log in a newly created user, causing fun!

fiddlerwoaroof authored on 15/10/2015 16:48:15
Showing 4 changed files
... ...
@@ -151,9 +151,9 @@ def submit_link():
151 151
 @bone_blueprint.route('', methods=['GET'])
152 152
 @login_required
153 153
 def default_data():
154
-    result = '', 401, {}
155
-    if 'username' in session:
156
-        result = data(current_user.id)
154
+    print current_user.id
155
+    print 'username' in session
156
+    result = data(current_user.id)
157 157
     return result
158 158
 
159 159
 @bone_blueprint.route('/u/<username>', methods=['GET'])
... ...
@@ -111,6 +111,7 @@ def adduser():
111 111
                 session['username'] = username
112 112
                 result['status'] = True
113 113
                 _get_users()
114
+                login_user(User.get_user(username))
114 115
             except psycopg2.IntegrityError as e:
115 116
                 db.rollback()
116 117
                 if e.pgcode == '23505': #username not unique
... ...
@@ -24,7 +24,7 @@ marrowApp.config(['$routeProvider',
24 24
         responseError: function(rejection) {
25 25
             if (rejection.status === 401) {
26 26
                 console.log("Response Error 401",rejection);
27
-                $window.location.href = '/login.html#' + encodeURIComponent($location.path());
27
+                $window.location.href = '/login.html';
28 28
             }
29 29
             return $q.reject(rejection);
30 30
         }
... ...
@@ -1,5 +1,6 @@
1 1
 window.URL = window.URL || window.webkitURL;
2
-var loginModule = angular.module('marrowLogin', ['ngResource','ngRoute','angulartics', 'angulartics.google.analytics']);
2
+var loginModule = angular.module('marrowLogin', ['ngResource','ngRoute','angulartics',
3
+                                 'angulartics.google.analytics', 'angulartics.piwik']);
3 4
 
4 5
 loginModule.controller('LoginCtrl', function ($scope,$http,$route,$window) {
5 6
   $scope.message = '';
... ...
@@ -14,10 +15,10 @@ loginModule.controller('LoginCtrl', function ($scope,$http,$route,$window) {
14 15
     });
15 16
   };
16 17
 
17
-  check_login().success(
18
-    function(is_loggedon) {
19
-      if (is_loggedon.result) { $window.location.href = '/';}
20
-  });
18
+  //check_login().success(
19
+  //  function(is_loggedon) {
20
+  //    if (is_loggedon.result) { $window.location.href = '/';}
21
+  //});
21 22
 
22 23
   $scope.newuser = function () {
23 24
     var username = $scope.username;