From d7597608d59dabd336c85bac270f46f645aeab31 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Wed, 10 Jul 2013 21:31:58 -0400 Subject: [PATCH] fixed login register logout --- public/src/forum/footer.js | 2 +- public/src/forum/login.js | 4 +-- public/src/modules/mobileMenu.js | 2 +- public/src/templates.js | 3 +- public/templates/register.tpl | 2 +- src/routes/authentication.js | 5 +-- src/webserver.js | 52 +++++++++++++++++--------------- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 2c3e265da0..abfd1af094 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -63,7 +63,7 @@ '); rightMenu.append(userli); - var logoutli = $('
  • Log out
  • '); + var logoutli = $('
  • Log out
  • '); rightMenu.append(logoutli); } } else { diff --git a/public/src/forum/login.js b/public/src/forum/login.js index 12370b0ef0..6753bdddbe 100644 --- a/public/src/forum/login.js +++ b/public/src/forum/login.js @@ -24,11 +24,11 @@ $.ajax({ type: "POST", - url: '/login', + url: RELATIVE_PATH + '/login', data: loginData, success: function(data, textStatus, jqXHR) { $('#login-error-notify').hide(); - window.location.replace("/"); + window.location.replace(RELATIVE_PATH + "/"); }, error : function(data, textStatus, jqXHR) { $('#login-error-notify').show().delay(1000).fadeOut(250); diff --git a/public/src/modules/mobileMenu.js b/public/src/modules/mobileMenu.js index 2ee74f12ad..115a0c750a 100644 --- a/public/src/modules/mobileMenu.js +++ b/public/src/modules/mobileMenu.js @@ -15,7 +15,7 @@ define(function() { return; } - jQuery.getJSON('/api/home', function(data) { + jQuery.getJSON(RELATIVE_PATH+'/api/home', function(data) { categories = data.categories; initialized = true; diff --git a/public/src/templates.js b/public/src/templates.js index 53befa5db6..1c1218bbcf 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -160,9 +160,8 @@ }()); (function() { - console.log(API_URL,api_url); - jQuery.get(API_URL + api_url, function(data) { + jQuery.get(API_URL + api_url, function(data) { if(!data) { ajaxify.go('404'); diff --git a/public/templates/register.tpl b/public/templates/register.tpl index 7b149091ef..0656336f43 100644 --- a/public/templates/register.tpl +++ b/public/templates/register.tpl @@ -1,7 +1,7 @@

    Register

    -
    +


    diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 4176b1e734..be27eaeb95 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -135,14 +135,15 @@ app.post('/register', function(req, res) { user_module.create(req.body.username, req.body.password, req.body.email, function(err, uid) { + if (err === null && uid > 0) { req.login({ uid: uid }, function() { - res.redirect('/'); + res.redirect(global.config.relative_path + '/'); }); } else { - res.redirect('/register'); + res.redirect(global.config.relative_path + '/register'); } }); }); diff --git a/src/webserver.js b/src/webserver.js index d3a8b79224..19e1b9ff15 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -110,36 +110,13 @@ var express = require('express'), res.json('500', { error: err.message }); }); - app.create_route = function(url, tpl) { // to remove return ''; }; - - // Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section) - (function() { - var routes = ['login', 'register', 'account', 'recent', 'popular', 'active', '403', '404']; - - for (var i=0, ii=routes.length; i 0)) { - - user.getUserField(req.user.uid, 'userslug', function(userslug) { - res.redirect('/users/'+userslug); - }); - return; - } - - res.send(app.build_header(res) + app.create_route(route) + templates['footer']); - }); - }(routes[i])); - } - }()); - // Complex Routes + app.namespace(global.config.relative_path, function() { auth.create_routes(app); @@ -147,9 +124,34 @@ var express = require('express'), userRoute.create_routes(app); installRoute.create_routes(app); testBed.create_routes(app); + + + + // Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section) + (function() { + var routes = ['login', 'register', 'account', 'recent', 'popular', 'active', '403', '404']; + + for (var i=0, ii=routes.length; i 0)) { + + user.getUserField(req.user.uid, 'userslug', function(userslug) { + res.redirect('/users/'+userslug); + }); + return; + } + + res.send(app.build_header(res) + app.create_route(route) + templates['footer']); + }); + }(routes[i])); + } + }()); + app.get('/', function(req, res) { - console.log('going in home'); + categories.getAllCategories(function(returnData) { res.send( app.build_header(res) +