#2844 fix accessCode flow
This commit is contained in:
38
dist/oauth2-redirect.html
vendored
38
dist/oauth2-redirect.html
vendored
@@ -33,51 +33,19 @@
|
||||
if (qp.code) {
|
||||
delete oauth2.state;
|
||||
oauth2.auth.code = qp.code;
|
||||
createForm(oauth2.auth, qp).submit();
|
||||
oauth2.callback(oauth2.auth);
|
||||
} else {
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: "Authorization failed: no accessCode came from the server"
|
||||
message: "Authorization failed: no accessCode received from the server"
|
||||
});
|
||||
window.close();
|
||||
}
|
||||
} else {
|
||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function createForm(auth, qp) {
|
||||
var form = document.createElement("form");
|
||||
var schema = auth.schema;
|
||||
var action = schema.get("tokenUrl");
|
||||
var name, input;
|
||||
|
||||
var fields = {
|
||||
code: qp.code,
|
||||
"redirect_uri": location.protocol + "//" + location.host + location.pathname,
|
||||
"grant_type": "authorization_code",
|
||||
"client_secret": auth.clientSecret,
|
||||
"client_id": auth.clientId
|
||||
}
|
||||
|
||||
for ( name in fields ) {
|
||||
input = document.createElement("input");
|
||||
input.name = name;
|
||||
input.value = fields[name];
|
||||
input.type = "hidden";
|
||||
form.appendChild(input);
|
||||
}
|
||||
|
||||
|
||||
form.method = "POST";
|
||||
form.action = action;
|
||||
|
||||
document.body.appendChild(form);
|
||||
|
||||
return form;
|
||||
window.close();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user