Skip to content

Commit dbf9c81

Browse files
committed
fix xapi js from simva received data
1 parent 4c8169c commit dbf9c81

1 file changed

Lines changed: 43 additions & 30 deletions

File tree

src/lib/xapi.js

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,59 @@ const xAPIConfig = {
22
"grant_type": "password"
33
}
44
const urlParams = new URLSearchParams(window.location.search);
5-
var simvaResultUri, simvaBackupUri, authToken, username, userToken, token_endpoint, client_id, login_hint, homepage,debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec;
5+
var result_uri,backup_uri, backup_type, actor_username, actor_homepage, debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec
66
if(urlParams.size > 0) {
7-
simvaResultUri = urlParams.get('url');
8-
simvaBackupUri=simvaResultUri + "/result";
9-
var token = urlParams.get('authToken');
10-
if(token) {
11-
authToken = "Bearer " + token;
12-
} else {
13-
authToken = null;
7+
//RESULT URI
8+
result_uri = urlParams.get('result_uri');
9+
//BACKUP URI
10+
backup_uri=urlParams.get('backup_uri');
11+
backup_type=urlParams.get('backup_type');
12+
13+
//ACTOR DATA
14+
actor_homepage = urlParams.get('actor_homepage');
15+
actor_username = urlParams.get('actor_user');
16+
17+
//SSO DATA
18+
const sso_token_endpoint = urlParams.get('sso_token_endpoint');
19+
if(sso_token_endpoint) {
20+
xAPIConfig.token_endpoint=sso_token_endpoint;
21+
}
22+
const sso_client_id = urlParams.get('sso_client_id');
23+
if(sso_client_id) {
24+
xAPIConfig.client_id=sso_client_id;
1425
}
15-
username = urlParams.get('username');
16-
token_endpoint = urlParams.get('token_endpoint');
17-
if(token_endpoint) {
18-
xAPIConfig.token_endpoint=token_endpoint;
26+
const sso_login_hint = urlParams.get('sso_login_hint');
27+
if(sso_login_hint) {
28+
xAPIConfig.login_hint=sso_login_hint;
1929
}
20-
client_id = urlParams.get('client_id');
21-
if(client_id) {
22-
xAPIConfig.client_id=client_id;
30+
const sso_grant_type = urlParams.get('sso_grant_type');
31+
if(sso_grant_type) {
32+
xAPIConfig.grant_type=sso_grant_type;
2333
}
24-
userToken = urlParams.get('usertoken');
25-
if(userToken) {
26-
xAPIConfig.username=userToken;
27-
xAPIConfig.password=userToken;
34+
const sso_username = urlParams.get('sso_username');
35+
if(sso_username) {
36+
xAPIConfig.username=sso_username;
2837
}
29-
login_hint = urlParams.get('login_hint');
30-
if(login_hint) {
31-
xAPIConfig.login_hint=login_hint;
38+
const sso_password = urlParams.get('sso_password');
39+
if(sso_password) {
40+
xAPIConfig.password=sso_password;
41+
} else {
42+
if(sso_username) {
43+
xAPIConfig.password=sso_username;
44+
}
3245
}
33-
homepage = urlParams.get('homepage');
46+
3447
debug=urlParams.get('debug');
3548
batchLength=urlParams.get('batchLength');
3649
batchTimeoutInSec=urlParams.get('batchTimeoutInSec');
3750
maxRetryDelayInSec=urlParams.get('maxRetryDelayInSec');
3851
if(debug !== null && debug == "true") {
3952
debug = Boolean(debug);
40-
console.debug(simvaBackupUri);
41-
console.debug(simvaResultUri);
42-
console.debug(authToken);
43-
console.debug(username);
44-
console.debug(homepage);
53+
console.debug(result_uri);
54+
console.debug(backup_uri);
55+
console.debug(backup_type);
56+
console.debug(actor_username);
57+
console.debug(actor_homepage);
4558
console.debug(debug);
4659
console.debug(batchLength);
4760
console.debug(batchTimeoutInSec);
@@ -56,8 +69,8 @@ if(urlParams.size > 0) {
5669
homepage = null;
5770
debug = false;
5871
}
59-
export var xapiTracker = new xAPITrackerAsset(simvaResultUri, simvaBackupUri, "XAPI", username, authToken, homepage, "ConectadoWeb", debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec);
60-
//export var xapiTracker = new xAPITrackerAssetOAuth2(simvaResultUri, simvaBackupUri, "XAPI", username, xAPIConfig, homepage, "ConectadoWeb", debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec);
72+
//export var xapiTracker = new xAPITrackerAsset(simvaResultUri, simvaBackupUri, "XAPI", username, authToken, homepage, "ConectadoWeb", debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec);
73+
export var xapiTracker = new xAPITrackerAssetOAuth2(result_uri, backup_uri, backup_type, actor_username, xAPIConfig, actor_homepage, "ConectadoWeb", debug, batchLength, batchTimeoutInSec, maxRetryDelayInSec);
6174
export var accessibleXapiTracker = new AccessibleTracker(xapiTracker);
6275
export var alternativeXapiTracker = new AlternativeTracker(xapiTracker);
6376
export var completableXapiTracker = new CompletableTracker(xapiTracker);

0 commit comments

Comments
 (0)