fix(core): Added logging for user email login process and fixed client URL parsing
This commit is contained in:
@@ -15,16 +15,16 @@ export class IdpClient {
|
||||
public rolesReplaySubject = new plugins.smartrx.rxjs.ReplaySubject(1);
|
||||
public organizationsReplaySubject = new plugins.smartrx.rxjs.ReplaySubject(1);
|
||||
|
||||
public receptionTrUrl: string;
|
||||
public parsedReceptionUrl: plugins.smarturl.Smarturl;
|
||||
constructor(receptionBaseUrlArg: string, appDataArg?: plugins.lointReception.data.IApp) {
|
||||
this.receptionTrUrl = receptionBaseUrlArg
|
||||
if (this.receptionTrUrl.endsWith('/')) {
|
||||
this.receptionTrUrl = this.receptionTrUrl.slice(0, -1);
|
||||
if (receptionBaseUrlArg.endsWith('/')) {
|
||||
receptionBaseUrlArg = receptionBaseUrlArg.slice(0, -1);
|
||||
}
|
||||
if (!this.receptionTrUrl.endsWith('/typedrequest')) {
|
||||
this.receptionTrUrl = `${this.receptionTrUrl}/typedrequest`;
|
||||
if (!receptionBaseUrlArg.endsWith('/typedrequest')) {
|
||||
receptionBaseUrlArg = `${receptionBaseUrlArg}/typedrequest`;
|
||||
}
|
||||
console.log(`reception client connecting to ${this.receptionTrUrl}`);
|
||||
this.parsedReceptionUrl = plugins.smarturl.Smarturl.createFromUrl(receptionBaseUrlArg);
|
||||
console.log(`reception client connecting to ${this.parsedReceptionUrl.toString()}`);
|
||||
if (!appDataArg) {
|
||||
appDataArg = {
|
||||
id: '', // TODO
|
||||
@@ -39,6 +39,11 @@ export class IdpClient {
|
||||
|
||||
public requests = new IdpRequests(this);
|
||||
|
||||
public checkWetherOnReceptionDomain() {
|
||||
return plugins.smarturl.Smarturl.createFromUrl(window.location.href).hostname ===
|
||||
this.parsedReceptionUrl.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* app data can be transferred when redirecting to the sso domain using query params
|
||||
* this message retrieves the app data when on the sso domain
|
||||
@@ -123,7 +128,7 @@ export class IdpClient {
|
||||
}
|
||||
const refreshJwtReq =
|
||||
new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_RefreshJwt>(
|
||||
`${this.receptionTrUrl}/typedrequest`,
|
||||
this.parsedReceptionUrl.toString(),
|
||||
'refreshJwt'
|
||||
);
|
||||
const response = await refreshJwtReq.fire({
|
||||
@@ -146,7 +151,7 @@ export class IdpClient {
|
||||
const extractedJwt = await this.helpers.extractDataFromJwtString(jwt);
|
||||
const getTransferToken =
|
||||
new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_ExchangeRefreshTokenAndTransferToken>(
|
||||
`${this.receptionTrUrl}/typedrequest`,
|
||||
this.parsedReceptionUrl.toString(),
|
||||
'exchangeRefreshTokenAndTransferToken'
|
||||
);
|
||||
const response = await getTransferToken.fire({
|
||||
@@ -184,7 +189,7 @@ export class IdpClient {
|
||||
if (transferToken) {
|
||||
const getTransferToken =
|
||||
new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_ExchangeRefreshTokenAndTransferToken>(
|
||||
`${this.receptionTrUrl}/typedrequest`,
|
||||
this.parsedReceptionUrl.toString(),
|
||||
'exchangeRefreshTokenAndTransferToken'
|
||||
);
|
||||
const response = await getTransferToken.fire({
|
||||
@@ -231,15 +236,14 @@ export class IdpClient {
|
||||
} else {
|
||||
if (requireLoginArg) {
|
||||
const urlInstance = plugins.smarturl.Smarturl.createFromUrl(
|
||||
'https://sso.workspace.global/',
|
||||
this.parsedReceptionUrl.clone().set('path', '/login').toString(),
|
||||
{
|
||||
searchParams: {
|
||||
appdata: plugins.smartjson.stringifyBase64(this.appData),
|
||||
action: 'login',
|
||||
},
|
||||
}
|
||||
);
|
||||
if (!globalThis.location.href.startsWith('https://sso.workspace.global/')) {
|
||||
if (!globalThis.location.href.startsWith(this.parsedReceptionUrl.toString())) {
|
||||
globalThis.location.href = urlInstance.toString();
|
||||
}
|
||||
}
|
||||
@@ -265,7 +269,7 @@ export class IdpClient {
|
||||
} else {
|
||||
// we are in the sso page
|
||||
await this.enableTypedSocket();
|
||||
console.log(`logging out against ${this.receptionTrUrl}`)
|
||||
console.log(`logging out against ${this.parsedReceptionUrl.toString()}`);
|
||||
const logoutTr =
|
||||
this.typedsocket.createTypedRequest<plugins.lointReception.request.ILogoutRequest>(
|
||||
'logout'
|
||||
@@ -292,7 +296,7 @@ export class IdpClient {
|
||||
this.typedsocketDeferred.claim();
|
||||
this.typedsocket = await plugins.typedsocket.TypedSocket.createClient(
|
||||
this.typedrouter,
|
||||
`${this.receptionTrUrl}/`
|
||||
this.parsedReceptionUrl.toString()
|
||||
);
|
||||
this.typedsocketDeferred.resolve(this.typedsocket);
|
||||
return this.typedsocketDeferred.promise;
|
||||
|
||||
@@ -12,21 +12,21 @@ export class IdpRequests {
|
||||
|
||||
public get afterRegistrationEmailClicked () {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_AfterRegistrationEmailClicked>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'afterRegistrationEmailClicked'
|
||||
);
|
||||
}
|
||||
|
||||
public get setData() {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_SetDataForRegistration>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'setDataForRegistration'
|
||||
);
|
||||
}
|
||||
|
||||
public get mobileNumberVerification () {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_MobileVerificationForRegistration>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'mobileVerificationForRegistration'
|
||||
);
|
||||
}
|
||||
@@ -34,28 +34,28 @@ export class IdpRequests {
|
||||
|
||||
public get finishRegistration() {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_FinishRegistration>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'finishRegistration'
|
||||
);
|
||||
}
|
||||
|
||||
public get loginWithUserNameAndPassword () {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_LoginWithEmailOrUsernameAndPassword>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'loginWithEmailOrUsernameAndPassword'
|
||||
);
|
||||
}
|
||||
|
||||
public get obtainJwt () {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_RefreshJwt>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'refreshJwt'
|
||||
);
|
||||
}
|
||||
|
||||
public get obtainOneTimeToken () {
|
||||
return new plugins.typedrequest.TypedRequest<plugins.lointReception.request.IReq_ExchangeRefreshTokenAndTransferToken>(
|
||||
this.idpClientArg.receptionTrUrl,
|
||||
this.idpClientArg.parsedReceptionUrl.toString(),
|
||||
'exchangeRefreshTokenAndTransferToken'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user