Redirect to the pad when logging in or signing up from a pad

pull/1/head
yflory 8 years ago
parent 92050eb04f
commit 71b84afdb2

@ -465,9 +465,11 @@ define([
window.location.href = '/'; window.location.href = '/';
}); });
$userAdmin.find('a.login').click(function (e) { $userAdmin.find('a.login').click(function (e) {
sessionStorage.redirectTo = window.location.href;
window.location.href = '/login/'; window.location.href = '/login/';
}); });
$userAdmin.find('a.register').click(function (e) { $userAdmin.find('a.register').click(function (e) {
sessionStorage.redirectTo = window.location.href;
window.location.href = '/register/'; window.location.href = '/register/';
}); });

@ -78,7 +78,17 @@ define([
result.proxy.login_name = result.userName; result.proxy.login_name = result.userName;
} }
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.login(result.userHash, result.userName, function () {
document.location.href = '/drive/'; if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo;
var parser = document.createElement('a');
parser.href = h;
if (parser.origin === window.location.origin) {
delete sessionStorage.redirectTo;
window.location.href = h;
return;
}
}
window.location.href = '/drive/';
}); });
return; return;
} }

@ -120,7 +120,17 @@ define([
Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.whenRealtimeSyncs(result.realtime, function () {
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.login(result.userHash, result.userName, function () {
document.location.href = '/drive/'; if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo;
var parser = document.createElement('a');
parser.href = h;
if (parser.origin === window.location.origin) {
delete sessionStorage.redirectTo;
window.location.href = h;
return;
}
}
window.location.href = '/drive/';
}); });
}); });
}); });

Loading…
Cancel
Save