Skip to content

Commit

Permalink
new overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Jan 3, 2017
1 parent aa97bd2 commit 69037f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 124 deletions.
122 changes: 0 additions & 122 deletions src/core/web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,125 +62,3 @@ class Auth0WebAPI {
}

export default new Auth0WebAPI();
<<<<<<< a1070ebfc887a0c369f1c8c8dacdb221a0d12f5c

function normalizeError(error) {
if (!error) {
return error;
}

// TODO: clean this mess, the first checks are for social/popup,
// then we have some stuff for passwordless and the latter is for
// db.

// TODO: the following checks were copied from https://github.com/auth0/lock/blob/0a5abf1957c9bb746b0710b274d0feed9b399958/index.js#L1263-L1288
// Some of the checks are missing because I couldn't reproduce them and I'm
// affraid they'll break existent functionality if add them.
// We need a better errror handling story in auth0.js.

if (error.status === "User closed the popup window") {
// {
// status: "User closed the popup window",
// name: undefined,
// code: undefined,
// details: {
// description: "server error",
// code: undefined
// }
// }
return {
code: "lock.popup_closed",
error: "lock.popup_closed",
description: "Popup window closed."
};
}

if (error.code === "unauthorized") {

// Custom rule error
//
// {
// "code": "unauthorized",
// "details": {
// "code": "unauthorized",
// "error_description": "user is blocked",
// "error": "unauthorized"
// },
// "name": "unauthorized",
// "status": 401
// }

// Default "user is blocked" rule error
//
// {
// "code": "unauthorized",
// "details": {
// "code": "unauthorized",
// "error_description": "user is blocked",
// "error": "unauthorized"
// },
// "name": "unauthorized",
// "status": 401
// }

// Social cancel permissions.
//
// {
// code: "unauthorized",
// details: {
// code: "unauthorized"
// error: "unauthorized"
// error_description: "access_denied"
// },
// name: "unauthorized"
// status: 401
// }

// Social cancel permissions or unknown error
if (!error.details
|| !error.details.error_description
|| error.details.error_description === "access_denied") {

return {
code: "lock.unauthorized",
error: "lock.unauthorized",
description: (error.details && error.details.error_description) || "Permissions were not granted."
}
}

// Special case for custom rule error
if (error.details.error_description === "user is blocked") {
return {
code: "blocked_user",
error: "blocked_user",
description: error.details.error_description
};
}

// Custom Rule error
return {
code: "rule_error",
error: "rule_error",
description: error.details.error_description
};

}

const result = {
error: error.details ? error.details.error : (error.code || error.statusCode || error.error),
description: error.details ? error.details.error_description : (error.error_description || error.description || error.error)
}

// result is used for passwordless and error for database.
return result.error === undefined && result.description === undefined
? error
: result;
}

function loginCallback(redirect, cb) {
return redirect
? error => cb(normalizeError(error))
: (error, result) => cb(normalizeError(error), result);
}
=======
>>>>>>> move legacy and p2 to different clases
4 changes: 3 additions & 1 deletion src/core/web_api/legacy_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class Auth0LegacyAPIClient {
responseMode: opts.responseMode,
responseType: opts.responseType,
_sendTelemetry: opts._sendTelemetry === false ? false : true,
_telemetryInfo: opts._telemetryInfo || default_telemetry
_telemetryInfo: opts._telemetryInfo || default_telemetry,
__tenant: opts.overrides && opts.overrides.__tenant,
__token_issuer: opts.overrides && opts.overrides.__token_issuer
});

this.authOpt = {
Expand Down
4 changes: 3 additions & 1 deletion src/core/web_api/p2_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class Auth0APIClient {
responseMode: opts.responseMode,
responseType: opts.responseType,
_sendTelemetry: opts._sendTelemetry === false ? false : true,
_telemetryInfo: opts._telemetryInfo || default_telemetry
_telemetryInfo: opts._telemetryInfo || default_telemetry,
__tenant: opts.overrides && opts.overrides.__tenant,
__token_issuer: opts.overrides && opts.overrides.__token_issuer
});

this.authOpt = {
Expand Down

0 comments on commit 69037f1

Please sign in to comment.