Skip to content

Node.js based forum software built for the modern web

fixed login register logout

Baris Soner Usaklid7597608d59d
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 @@
</li>');
rightMenu.append(userli);
- var logoutli = $('<li><a href="/logout">Log out</a></li>');
+ var logoutli = $('<li><a href="' + RELATIVE_PATH + '/logout">Log out</a></li>');
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 @@
<h1>Register</h1>
<div class="row-fluid">
<div class="well {register_window:spansize}">
- <form method="post" action="/register">
+ <form method="post" action="{relative_path}/register">
<label for="email">Email Address</label><input type="email" name="email" placeholder="Enter Email Address" id="email" /> <span id="email-notify" class="label label-important"></span><br />
<label for="username">Username</label><input type="text" name="username" placeholder="Enter Username" id="username" /> <span id="username-notify" class="label label-success"></span> <br />
<label for="password">Password</label><input type="password" name="password" placeholder="Enter Password" id="password" /> <span id="password-notify" class="label label-important"></span> <br />
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 '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});</script>';
};
-
- // 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<ii; i++) {
- (function(route) {
-
- app.get('/' + route, function(req, res) {
- if ((route === 'login' || route ==='register') && (req.user && req.user.uid > 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<ii; i++) {
+ (function(route) {
+
+ app.get('/' + route, function(req, res) {
+ if ((route === 'login' || route ==='register') && (req.user && req.user.uid > 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) +