from maildir import *
from utils import serialize_json
+@get('/kite/auth')
+def index():
+ response.status = 200
+ response.set_cookie('XSRF-TOKEN', "blah", max_age=86400)
+ return
+
@post('/kite/auth')
def index():
username = request.json.get('username', None)
$routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'LoginController'});
$routeProvider.when('/thread/:id', {templateUrl: 'partials/thread.html', controller: 'ThreadController'});
$routeProvider.otherwise({redirectTo: '/login'});
+ }]).run(['$rootScope', '$location', 'Auth', function($rootScope, $location, Auth) {
+ $rootScope.$on( "$routeChangeStart", function(event, next, current) {
+ console.log(Auth.loggedOn());
+ if (!Auth.loggedOn()) {
+ // no logged user, redirect to /login
+ if (next.templateUrl != "partials/login.html") {
+ $location.path("/login");
+ }
+ }
+ });
}]);
var _isAuth = false;
var _username = null
return {
- isAuth: _isAuth,
+ loggedOn: function() { return _isAuth },
username: _username,
doLogin: function(username, password, success, failure) {
_username = username;
$http({url: '/kite/auth', method:'POST', data: {"username": username, "password": password}}).
success(function(data, status, headers, config) {
+ _isAuth = true;
success(data);
});
},