@5calls/react-components
Version:
React component library for 5 Calls webapp
57 lines (56 loc) • 2.34 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var react_router_1 = require("react-router");
var LoginService_1 = require("./LoginService");
var Auth0Callback = /** @class */ (function (_super) {
__extends(Auth0Callback, _super);
function Auth0Callback(props) {
var _this = _super.call(this, props) || this;
_this.state = { doneRedirect: false };
_this.loginService = new LoginService_1.LoginService(_this.props.auth0Config);
return _this;
}
Auth0Callback.prototype.componentDidMount = function () {
var _this = this;
this.loginService.handleAuthentication().then(function (response) {
_this.props.handleAuthentication(response).then(function (response) {
window.setTimeout(function () {
_this.setState({ doneRedirect: true });
}, 500);
});
});
};
Auth0Callback.prototype.render = function () {
if (this.state.doneRedirect) {
var redirect = this.props.redirectPath ?
this.props.redirectPath : '/';
if (window.opener) {
window.opener.postMessage('authenticationDone', '*');
}
return React.createElement(react_router_1.Redirect, { to: redirect });
}
else {
return React.createElement("h1", null, "Logging you in...");
}
};
return Auth0Callback;
}(React.Component));
exports.Auth0Callback = Auth0Callback;