fixed login register logout

v1.18.x
Baris Soner Usakli 12 years ago
parent 43e73e3aba
commit d7597608d5

@ -63,7 +63,7 @@
</li>'); </li>');
rightMenu.append(userli); 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); rightMenu.append(logoutli);
} }
} else { } else {

@ -24,11 +24,11 @@
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/login', url: RELATIVE_PATH + '/login',
data: loginData, data: loginData,
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
$('#login-error-notify').hide(); $('#login-error-notify').hide();
window.location.replace("/"); window.location.replace(RELATIVE_PATH + "/");
}, },
error : function(data, textStatus, jqXHR) { error : function(data, textStatus, jqXHR) {
$('#login-error-notify').show().delay(1000).fadeOut(250); $('#login-error-notify').show().delay(1000).fadeOut(250);

@ -15,7 +15,7 @@ define(function() {
return; return;
} }
jQuery.getJSON('/api/home', function(data) { jQuery.getJSON(RELATIVE_PATH+'/api/home', function(data) {
categories = data.categories; categories = data.categories;
initialized = true; initialized = true;

@ -160,9 +160,8 @@
}()); }());
(function() { (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) { if(!data) {
ajaxify.go('404'); ajaxify.go('404');

@ -1,7 +1,7 @@
<h1>Register</h1> <h1>Register</h1>
<div class="row-fluid"> <div class="row-fluid">
<div class="well {register_window:spansize}"> <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="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="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 /> <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 />

@ -135,14 +135,15 @@
app.post('/register', function(req, res) { app.post('/register', function(req, res) {
user_module.create(req.body.username, req.body.password, req.body.email, function(err, uid) { user_module.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
if (err === null && uid > 0) { if (err === null && uid > 0) {
req.login({ req.login({
uid: uid uid: uid
}, function() { }, function() {
res.redirect('/'); res.redirect(global.config.relative_path + '/');
}); });
} else { } else {
res.redirect('/register'); res.redirect(global.config.relative_path + '/register');
} }
}); });
}); });

@ -110,36 +110,13 @@ var express = require('express'),
res.json('500', { error: err.message }); res.json('500', { error: err.message });
}); });
app.create_route = function(url, tpl) { // to remove app.create_route = function(url, tpl) { // to remove
return '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});</script>'; 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() { app.namespace(global.config.relative_path, function() {
auth.create_routes(app); auth.create_routes(app);
@ -147,9 +124,34 @@ var express = require('express'),
userRoute.create_routes(app); userRoute.create_routes(app);
installRoute.create_routes(app); installRoute.create_routes(app);
testBed.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) { app.get('/', function(req, res) {
console.log('going in home');
categories.getAllCategories(function(returnData) { categories.getAllCategories(function(returnData) {
res.send( res.send(
app.build_header(res) + app.build_header(res) +

Loading…
Cancel
Save