Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix U2F if gitea is configured in subpath #5302

Merged
merged 2 commits into from
Nov 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ function initU2FAuth() {
}
u2fApi.ensureSupport()
.then(function () {
$.getJSON('/user/u2f/challenge').success(function(req) {
$.getJSON(suburl + '/user/u2f/challenge').success(function(req) {
u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30)
.then(u2fSigned)
.catch(function (err) {
Expand All @@ -1543,16 +1543,16 @@ function initU2FAuth() {
});
}).catch(function () {
// Fallback in case browser do not support U2F
window.location.href = "/user/two_factor"
window.location.href = suburl + "/user/two_factor"
})
}
function u2fSigned(resp) {
$.ajax({
url:'/user/u2f/sign',
type:"POST",
url: suburl + '/user/u2f/sign',
type: "POST",
headers: {"X-Csrf-Token": csrf},
data: JSON.stringify(resp),
contentType:"application/json; charset=utf-8",
contentType: "application/json; charset=utf-8",
}).done(function(res){
window.location.replace(res);
}).fail(function (xhr, textStatus) {
Expand All @@ -1565,11 +1565,11 @@ function u2fRegistered(resp) {
return;
}
$.ajax({
url:'/user/settings/security/u2f/register',
type:"POST",
url: suburl + '/user/settings/security/u2f/register',
type: "POST",
headers: {"X-Csrf-Token": csrf},
data: JSON.stringify(resp),
contentType:"application/json; charset=utf-8",
contentType: "application/json; charset=utf-8",
success: function(){
window.location.reload();
},
Expand Down Expand Up @@ -1623,7 +1623,7 @@ function initU2FRegister() {
}

function u2fRegisterRequest() {
$.post("/user/settings/security/u2f/request_register", {
$.post(suburl + "/user/settings/security/u2f/request_register", {
"_csrf": csrf,
"name": $('#nickname').val()
}).success(function(req) {
Expand Down