From 6a697900bd2c058bd355ae01a924086793244ce2 Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Tue, 20 May 2025 18:24:52 +0300 Subject: [PATCH] login into demo account --- frontend/src/app/app.component.ts | 6 +++++- frontend/src/app/services/auth.service.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 6fefe404e..cf489be26 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -5,6 +5,7 @@ import { catchError, filter, map } from 'rxjs/operators'; import { Angulartics2Amplitude } from 'angulartics2'; import { AuthService } from './services/auth.service'; import { CommonModule } from '@angular/common'; +import { CompanyService } from './services/company.service'; import { ConnectionsService } from './services/connections.service'; import { DomSanitizer } from '@angular/platform-browser'; import { FeatureNotificationComponent } from './components/feature-notification/feature-notification.component'; @@ -27,7 +28,6 @@ import { UserService } from './services/user.service'; import amplitude from 'amplitude-js'; import { differenceInMilliseconds } from 'date-fns'; import { environment } from '../environments/environment'; -import { CompanyService } from './services/company.service'; //@ts-ignore window.amplitude = amplitude; @@ -115,6 +115,10 @@ export class AppComponent { ) .subscribe(() => { this.page = this.router.routerState.snapshot.url; + + if (this.router.routerState.snapshot.root.queryParams.mode === 'demo') { + this._auth.loginToDemoAccount().subscribe(); + } }) const expirationDateFromURL = new URLSearchParams(location.search).get('expires'); diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index 9e4dac123..2733a0625 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -272,4 +272,26 @@ export class AuthService { }) ); } + + loginToDemoAccount() { + const config = this._configuration.getConfig(); + return this._http.post(config.saasURL + '/saas/user/demo/register', undefined) + .pipe( + map(res => { + this.auth.next(res); + return res + }), + catchError((err) => { + console.log(err); + this._notifications.showAlert(AlertType.Error, {abstract: err.error.message || err.message, details: err.error.originalMessage}, [ + { + type: AlertActionType.Button, + caption: 'Dismiss', + action: () => this._notifications.dismissAlert() + } + ]); + return EMPTY; + }) + ); + } }