diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts b/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts
index d88dfb6be..822829221 100644
--- a/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts
+++ b/web/projects/start-tunnel/src/app/routes/home/routes/devices/add.ts
@@ -52,6 +52,7 @@ import { getIp, DeviceData, MappedSubnet, subnetValidator } from './utils'
} @else {
@@ -87,9 +88,7 @@ import { getIp, DeviceData, MappedSubnet, subnetValidator } from './utils'
}
}
`,
@@ -147,6 +146,7 @@ export class DevicesAdd {
protected async onSave() {
if (this.form.invalid) {
tuiMarkControlAsTouchedAndValidate(this.form)
+
return
}
diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/devices/utils.ts b/web/projects/start-tunnel/src/app/routes/home/routes/devices/utils.ts
index 6e083ea4f..959d99145 100644
--- a/web/projects/start-tunnel/src/app/routes/home/routes/devices/utils.ts
+++ b/web/projects/start-tunnel/src/app/routes/home/routes/devices/utils.ts
@@ -25,7 +25,9 @@ export interface DeviceData {
}
export function subnetValidator({ value }: AbstractControl) {
- return value && getIp(value) ? null : { noHosts: 'No hosts available' }
+ return !value?.clients || getIp(value)
+ ? null
+ : { noHosts: 'No hosts available' }
}
export function getIp({ clients, range }: MappedSubnet) {
diff --git a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts
index 96657b288..5c3e50b2a 100644
--- a/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts
+++ b/web/projects/start-tunnel/src/app/routes/home/routes/port-forwards/add.ts
@@ -39,6 +39,7 @@ import { MappedDevice, PortForwardsData } from './utils'
} @else {
@@ -76,6 +77,7 @@ import { MappedDevice, PortForwardsData } from './utils'
} @else {
diff --git a/web/projects/start-tunnel/src/app/services/auth.service.ts b/web/projects/start-tunnel/src/app/services/auth.service.ts
index fd1d33b2d..2635221d8 100644
--- a/web/projects/start-tunnel/src/app/services/auth.service.ts
+++ b/web/projects/start-tunnel/src/app/services/auth.service.ts
@@ -1,8 +1,20 @@
-import { Injectable, signal } from '@angular/core'
+import { effect, inject, Injectable, signal } from '@angular/core'
+import { WA_LOCAL_STORAGE } from '@ng-web-apis/common'
+
+const KEY = '_startos/tunnel-loggedIn'
@Injectable({
providedIn: 'root',
})
export class AuthService {
- readonly authenticated = signal(false)
+ private readonly storage = inject(WA_LOCAL_STORAGE)
+ private readonly effect = effect(() => {
+ if (this.authenticated()) {
+ this.storage.setItem(KEY, JSON.stringify(true))
+ } else {
+ this.storage.removeItem(KEY)
+ }
+ })
+
+ readonly authenticated = signal(Boolean(this.storage.getItem(KEY)))
}
diff --git a/web/projects/ui/src/app/services/storage.service.ts b/web/projects/ui/src/app/services/storage.service.ts
index 1ea9b0290..5f4e3e6b5 100644
--- a/web/projects/ui/src/app/services/storage.service.ts
+++ b/web/projects/ui/src/app/services/storage.service.ts
@@ -1,4 +1,5 @@
-import { Inject, Injectable, DOCUMENT } from '@angular/core'
+import { inject, Injectable } from '@angular/core'
+import { WA_LOCAL_STORAGE } from '@ng-web-apis/common'
const PREFIX = '_startos/'
@@ -6,9 +7,7 @@ const PREFIX = '_startos/'
providedIn: 'root',
})
export class StorageService {
- private readonly storage = this.document.defaultView!.localStorage
-
- constructor(@Inject(DOCUMENT) private readonly document: Document) {}
+ private readonly storage = inject(WA_LOCAL_STORAGE)
get(key: string): T {
return JSON.parse(String(this.storage.getItem(`${PREFIX}${key}`)))