Skip to content

Commit 8c4397c

Browse files
guguclaude
andcommitted
extract demo-login into separate component, improve hostname validator
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 parents 4b5dba4 + f314fa8 commit 8c4397c

13 files changed

Lines changed: 164 additions & 167 deletions

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"langchain": "^1.2.34",
8080
"lru-cache": "^11.2.7",
8181
"nanoid": "5.1.7",
82-
"nodemailer": "^8.0.2",
82+
"nodemailer": "^8.0.4",
8383
"nunjucks": "^3.2.4",
8484
"openai": "^6.32.0",
8585
"otplib": "^12.0.1",

frontend/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
},
1818
"private": true,
1919
"dependencies": {
20-
"@angular/animations": "~20.3.16",
20+
"@angular/animations": "~20.3.18",
2121
"@angular/cdk": "~20.2.14",
22-
"@angular/common": "~20.3.16",
23-
"@angular/compiler": "~20.3.16",
24-
"@angular/core": "~20.3.16",
25-
"@angular/forms": "~20.3.16",
22+
"@angular/common": "~20.3.18",
23+
"@angular/compiler": "~20.3.18",
24+
"@angular/core": "~20.3.18",
25+
"@angular/forms": "~20.3.18",
2626
"@angular/material": "~20.2.14",
27-
"@angular/platform-browser": "~20.3.16",
28-
"@angular/platform-browser-dynamic": "~20.3.16",
29-
"@angular/router": "~20.3.16",
27+
"@angular/platform-browser": "~20.3.18",
28+
"@angular/platform-browser-dynamic": "~20.3.18",
29+
"@angular/router": "~20.3.18",
3030
"@brumeilde/ngx-theme": "^1.2.1",
3131
"@cedar-policy/cedar-wasm": "^4.9.1",
3232
"@fontsource/ibm-plex-mono": "^5.2.7",
@@ -55,7 +55,7 @@
5555
"knip": "^5.79.0",
5656
"libphonenumber-js": "^1.12.9",
5757
"lodash": "^4.17.21",
58-
"lodash-es": "^4.17.21",
58+
"lodash-es": "^4.17.23",
5959
"mermaid": "^11.12.1",
6060
"monaco-editor": "0.55.1",
6161
"ng-dynamic-component": "^10.8.0",
@@ -66,7 +66,6 @@
6666
"pluralize": "^8.0.0",
6767
"postgres-interval": "^4.0.2",
6868
"posthog-js": "^1.341.0",
69-
"private-ip": "^3.0.2",
7069
"puppeteer": "^24.29.1",
7170
"rxjs": "^7.4.0",
7271
"tslib": "^2.8.1",
@@ -78,8 +77,8 @@
7877
"@angular-devkit/build-angular": "20",
7978
"@angular/build": "20.3.14",
8079
"@angular/cli": "~20.3.14",
81-
"@angular/compiler-cli": "~20.3.16",
82-
"@angular/language-service": "~20.3.16",
80+
"@angular/compiler-cli": "~20.3.18",
81+
"@angular/language-service": "~20.3.18",
8382
"@sentry-internal/rrweb": "^2.16.0",
8483
"@storybook/angular": "^10.2.14",
8584
"@types/node": "^22.10.2",
@@ -93,7 +92,8 @@
9392
},
9493
"resolutions": {
9594
"mermaid": "^11.10.0",
96-
"webpack": "5.104.1"
95+
"webpack": "5.104.1",
96+
"lodash-es": "4.17.23"
9797
},
9898
"packageManager": "yarn@1.22.22"
9999
}

frontend/src/app/app-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const routes: Routes = [
2828
canActivate: [configurationGuard],
2929
title: 'Login | Rocketadmin',
3030
},
31+
{
32+
path: 'demo',
33+
loadComponent: () => import('./components/demo-login/demo-login.component').then((m) => m.DemoLoginComponent),
34+
title: 'Demo | Rocketadmin',
35+
},
3136
{
3237
path: 'forget-password',
3338
loadComponent: () =>

frontend/src/app/app.component.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DomSanitizer } from '@angular/platform-browser';
1313
import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router';
1414
import { User } from '@sentry/angular';
1515
import amplitude from 'amplitude-js';
16-
import { Angulartics2, Angulartics2Amplitude, Angulartics2OnModule } from 'angulartics2';
16+
import { Angulartics2Amplitude, Angulartics2OnModule } from 'angulartics2';
1717
import { differenceInMilliseconds } from 'date-fns';
1818
import posthog from 'posthog-js';
1919
import { Subject } from 'rxjs';
@@ -95,7 +95,6 @@ export class AppComponent {
9595
_tables: TablesService,
9696
private _uiSettings: UiSettingsService,
9797
angulartics2Amplitude: Angulartics2Amplitude,
98-
private angulartics2: Angulartics2,
9998
private domSanitizer: DomSanitizer,
10099
private matIconRegistry: MatIconRegistry,
101100
_posthog: PosthogService,
@@ -168,16 +167,6 @@ export class AppComponent {
168167
this.page = this.router.routerState.snapshot.url.split('?')[0];
169168

170169
console.log('Navigated to page:', this.page);
171-
172-
if (this.router.routerState.snapshot.root.queryParams.mode === 'demo') {
173-
console.log('App component, demo mode search params found');
174-
this._auth.loginToDemoAccount().subscribe(() => {
175-
this.angulartics2.eventTrack.next({
176-
action: 'Demo account is logged in',
177-
});
178-
posthog.capture('Demo account is logged in');
179-
});
180-
}
181170
});
182171

183172
const expirationDateFromURL = new URLSearchParams(location.search).get('expires');
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.wrapper {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
min-height: 100vh;
6+
}
7+
8+
.demo-loader {
9+
display: flex;
10+
flex-direction: column;
11+
justify-content: center;
12+
align-items: center;
13+
gap: 24px;
14+
}
15+
16+
.demo-loader__text {
17+
color: var(--mat-sidenav-content-text-color);
18+
margin: 0;
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="wrapper background-decoration">
2+
<div class="demo-loader">
3+
<mat-spinner diameter="48"></mat-spinner>
4+
<p class="mat-body-1 demo-loader__text">Loading demo account...</p>
5+
</div>
6+
</div>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
3+
import { Angulartics2 } from 'angulartics2';
4+
import posthog from 'posthog-js';
5+
import { AuthService } from 'src/app/services/auth.service';
6+
7+
@Component({
8+
selector: 'app-demo-login',
9+
templateUrl: './demo-login.component.html',
10+
styleUrls: ['./demo-login.component.css'],
11+
imports: [MatProgressSpinnerModule],
12+
})
13+
export class DemoLoginComponent implements OnInit {
14+
constructor(
15+
private _auth: AuthService,
16+
private angulartics2: Angulartics2,
17+
) {}
18+
19+
ngOnInit(): void {
20+
this._auth.loginToDemoAccount().subscribe(() => {
21+
this.angulartics2.eventTrack.next({
22+
action: 'Demo account is logged in',
23+
});
24+
posthog.capture('Demo account is logged in');
25+
});
26+
}
27+
}

frontend/src/app/components/login/login.component.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,3 @@
360360
transform: translateX(100%);
361361
}
362362
}
363-
364-
.demo-loader {
365-
display: flex;
366-
flex-direction: column;
367-
justify-content: center;
368-
align-items: center;
369-
gap: 24px;
370-
}
371-
372-
.demo-loader__text {
373-
color: var(--mat-sidenav-content-text-color);
374-
margin: 0;
375-
}

frontend/src/app/components/login/login.component.html

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<app-alert></app-alert>
22

3-
@if (isDemoMode) {
4-
<div class="wrapper background-decoration">
5-
<div class="login-page demo-loader">
6-
<mat-spinner diameter="48"></mat-spinner>
7-
<p class="mat-body-1 demo-loader__text">Loading demo account...</p>
8-
</div>
9-
</div>
10-
} @else {
113
<div class="wrapper background-decoration">
124
<div class="login-page">
135
<form
@@ -20,7 +12,8 @@
2012
(ngSubmit)="(user.companyId || isCustomDomain) && user.password ? loginUser() : requestUserCompanies()">
2113

2214
<div class="login-header">
23-
<svg class="login-header__logo" width="56" height="54" viewBox="0 0 56 54" fill="none" xmlns="http://www.w3.org/2000/svg">
15+
<svg class="login-header__logo" width="56" height="54" viewBox="0 0 56 54" fill="none" xmlns="http://www.w3.org/2000/svg" role="img">
16+
<title>Rocketadmin logo</title>
2417
<path d="M47.2367 17.9125H35.1499C33.3671 17.9125 32.4833 16.5678 33.1783 14.9286L37.5295 4.71527C38.5191 2.39612 37.2651 0.5 34.742 0.5H23.4711C22.3682 0.5 21.1142 1.33097 20.6836 2.34323L15.4485 14.634C14.5798 16.6661 15.6827 18.328 17.8885 18.328H29.4465C30.7231 18.328 31.8789 19.0909 32.3775 20.2618L37.5295 32.3486C38.232 33.9954 37.3406 35.3401 35.5578 35.3401H8.62703C7.52411 35.3401 6.27011 36.1711 5.83952 37.1833L0.823517 48.9453C-0.166086 51.2644 1.08792 53.1605 3.61103 53.1605H29.8242C30.9271 53.1605 32.1811 52.3296 32.6117 51.3173L38.4435 37.629C38.9346 36.4808 40.0526 35.7405 41.299 35.7405H52.6833C54.9722 35.7405 56.1053 34.0181 55.2064 31.918L50.0242 19.7633C49.5936 18.751 48.3396 17.92 47.2367 17.92V17.9125Z" fill="#08041B"/>
2518
</svg>
2619
<h1 class="mat-headline-4 loginTitle">
@@ -100,7 +93,8 @@ <h1 class="mat-headline-4 loginTitle">
10093
angulartics2On="click"
10194
angularticsAction="Login: login with sso is clicked"
10295
(click)="openLoginWithSSOdialog(); posthog.capture('Login: login with sso is clicked')">
103-
<svg class="login-form__sso-icon" viewBox="0 0 18 24" fill="none" xmlns="http://www.w3.org/2000/svg">
96+
<svg class="login-form__sso-icon" viewBox="0 0 18 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img">
97+
<title>SSO login</title>
10498
<path d="M15.75 8.21393H14.625V5.96393C14.625 2.85893 12.105 0.338928 9 0.338928C5.895 0.338928 3.375 2.85893 3.375 5.96393V8.21393H2.25C1.0125 8.21393 0 9.22643 0 10.4639V21.7139C0 22.9514 1.0125 23.9639 2.25 23.9639H15.75C16.9875 23.9639 18 22.9514 18 21.7139V10.4639C18 9.22643 16.9875 8.21393 15.75 8.21393ZM9 18.3389C7.7625 18.3389 6.75 17.3264 6.75 16.0889C6.75 14.8514 7.7625 13.8389 9 13.8389C10.2375 13.8389 11.25 14.8514 11.25 16.0889C11.25 17.3264 10.2375 18.3389 9 18.3389ZM12.4875 8.21393H5.5125V5.96393C5.5125 4.04018 7.07625 2.47643 9 2.47643C10.9237 2.47643 12.4875 4.04018 12.4875 5.96393V8.21393Z" fill="#212121"/>
10599
</svg>
106100
<span class="login-form__sso-caption">Continue with SSO</span>
@@ -145,5 +139,4 @@ <h2 class="mat-headline-4 qr-verification__title">Enter 2nd factor code</h2>
145139
</form>
146140
</div>
147141
</div>
148-
}
149142

frontend/src/app/components/login/login.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import { MatDialog } from '@angular/material/dialog';
66
import { MatFormFieldModule } from '@angular/material/form-field';
77
import { MatIconModule } from '@angular/material/icon';
88
import { MatInputModule } from '@angular/material/input';
9-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
109
import { MatSelectModule } from '@angular/material/select';
11-
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
10+
import { Router, RouterModule } from '@angular/router';
1211
import { Angulartics2, Angulartics2OnModule } from 'angulartics2';
1312
import { accounts } from 'google-one-tap';
1413
import posthog from 'posthog-js';
@@ -37,7 +36,6 @@ declare var google: any;
3736
MatSelectModule,
3837
MatIconModule,
3938
MatButtonModule,
40-
MatProgressSpinnerModule,
4139
EmailValidationDirective,
4240
AlertComponent,
4341
Angulartics2OnModule,
@@ -59,7 +57,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
5957
public submitting: boolean;
6058
public isPasswordFieldShown: boolean = false;
6159
public is2FAShown: boolean = false;
62-
public isDemoMode: boolean = false;
6360
public errors = {
6461
'No_user_registered_with_this_GitHub_account.': 'No user registered with this GitHub account.',
6562
'GitHub_login_failed._Please_contact_our_support_team.': 'GitHub login failed. Please contact our support team.',
@@ -68,7 +65,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
6865
constructor(
6966
private _auth: AuthService,
7067
public router: Router,
71-
private _route: ActivatedRoute,
7268
private angulartics2: Angulartics2,
7369
private ngZone: NgZone,
7470
private _notifications: NotificationsService,
@@ -77,7 +73,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
7773
) {}
7874

7975
ngOnInit(): void {
80-
this.isDemoMode = this._route.snapshot.queryParams['mode'] === 'demo';
8176
this.isCustomDomain = this._company.isCustomDomain() && this.isSaas;
8277

8378
const error = new URLSearchParams(location.search).get('error');
@@ -92,7 +87,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
9287
}
9388

9489
ngAfterViewInit() {
95-
if (this.isSaas && !this.isDemoMode) {
90+
if (this.isSaas) {
9691
const gAccounts: accounts = google.accounts;
9792
gAccounts.id.initialize({
9893
client_id: '681163285738-e4l0lrv5vv7m616ucrfhnhso9r396lum.apps.googleusercontent.com',

0 commit comments

Comments
 (0)