Commit 95c2bfe7 authored by Mark Harding's avatar Mark Harding
Browse files

(fix): pro sites should wait for configs to be resolved

parent a4d3e5e9
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -6,15 +6,12 @@ import { ConfigsService } from './configs.service';


@Injectable()
@Injectable()
export class SsoService {
export class SsoService {
  protected readonly siteUrl: string;

  constructor(
  constructor(
    protected site: SiteService,
    protected site: SiteService,
    protected client: Client,
    protected client: Client,
    protected session: Session,
    protected session: Session,
    configs: ConfigsService
    private configs: ConfigsService
  ) {
  ) {
    this.siteUrl = configs.get('site_url');
    this.listen();
    this.listen();
  }
  }


@@ -33,7 +30,7 @@ export class SsoService {
  async connect() {
  async connect() {
    try {
    try {
      const connect: any = await this.client.postRaw(
      const connect: any = await this.client.postRaw(
        `${this.siteUrl}api/v2/sso/connect`
        `${this.configs.get('site_url')}api/v2/sso/connect`
      );
      );


      if (connect && connect.token && connect.status === 'success') {
      if (connect && connect.token && connect.status === 'success') {
@@ -58,9 +55,12 @@ export class SsoService {
      const connect: any = await this.client.post('api/v2/sso/connect');
      const connect: any = await this.client.post('api/v2/sso/connect');


      if (connect && connect.token && connect.status === 'success') {
      if (connect && connect.token && connect.status === 'success') {
        await this.client.postRaw(`${this.siteUrl}api/v2/sso/authorize`, {
        await this.client.postRaw(
          `${this.configs.get('site_url')}api/v2/sso/authorize`,
          {
            token: connect.token,
            token: connect.token,
        });
          }
        );
      }
      }
    } catch (e) {
    } catch (e) {
      console.error(e);
      console.error(e);