|
|
@ -1530,7 +1530,7 @@ function initU2FAuth() { |
|
|
|
} |
|
|
|
} |
|
|
|
u2fApi.ensureSupport() |
|
|
|
u2fApi.ensureSupport() |
|
|
|
.then(function () { |
|
|
|
.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) |
|
|
|
u2fApi.sign(req.appId, req.challenge, req.registeredKeys, 30) |
|
|
|
.then(u2fSigned) |
|
|
|
.then(u2fSigned) |
|
|
|
.catch(function (err) { |
|
|
|
.catch(function (err) { |
|
|
@ -1543,16 +1543,16 @@ function initU2FAuth() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}).catch(function () { |
|
|
|
}).catch(function () { |
|
|
|
// Fallback in case browser do not support U2F
|
|
|
|
// Fallback in case browser do not support U2F
|
|
|
|
window.location.href = "/user/two_factor" |
|
|
|
window.location.href = suburl + "/user/two_factor" |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
function u2fSigned(resp) { |
|
|
|
function u2fSigned(resp) { |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url:'/user/u2f/sign', |
|
|
|
url: suburl + '/user/u2f/sign', |
|
|
|
type:"POST", |
|
|
|
type: "POST", |
|
|
|
headers: {"X-Csrf-Token": csrf}, |
|
|
|
headers: {"X-Csrf-Token": csrf}, |
|
|
|
data: JSON.stringify(resp), |
|
|
|
data: JSON.stringify(resp), |
|
|
|
contentType:"application/json; charset=utf-8", |
|
|
|
contentType: "application/json; charset=utf-8", |
|
|
|
}).done(function(res){ |
|
|
|
}).done(function(res){ |
|
|
|
window.location.replace(res); |
|
|
|
window.location.replace(res); |
|
|
|
}).fail(function (xhr, textStatus) { |
|
|
|
}).fail(function (xhr, textStatus) { |
|
|
@ -1565,11 +1565,11 @@ function u2fRegistered(resp) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url:'/user/settings/security/u2f/register', |
|
|
|
url: suburl + '/user/settings/security/u2f/register', |
|
|
|
type:"POST", |
|
|
|
type: "POST", |
|
|
|
headers: {"X-Csrf-Token": csrf}, |
|
|
|
headers: {"X-Csrf-Token": csrf}, |
|
|
|
data: JSON.stringify(resp), |
|
|
|
data: JSON.stringify(resp), |
|
|
|
contentType:"application/json; charset=utf-8", |
|
|
|
contentType: "application/json; charset=utf-8", |
|
|
|
success: function(){ |
|
|
|
success: function(){ |
|
|
|
window.location.reload(); |
|
|
|
window.location.reload(); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1623,7 +1623,7 @@ function initU2FRegister() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function u2fRegisterRequest() { |
|
|
|
function u2fRegisterRequest() { |
|
|
|
$.post("/user/settings/security/u2f/request_register", { |
|
|
|
$.post(suburl + "/user/settings/security/u2f/request_register", { |
|
|
|
"_csrf": csrf, |
|
|
|
"_csrf": csrf, |
|
|
|
"name": $('#nickname').val() |
|
|
|
"name": $('#nickname').val() |
|
|
|
}).success(function(req) { |
|
|
|
}).success(function(req) { |
|
|
|