Skip to content

Commit

Permalink
always show login from localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDHill committed Sep 15, 2023
1 parent cf7c395 commit 23f3f32
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frontend/projects/shared/src/types/workspace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type WorkspaceConfig = {
community: 'https://community-registry.start9.com/'
}
mocks: {
maskAs: 'tor' | 'lan'
maskAs: 'tor' | 'local' | 'localhost'
// enables local development in secure mode
maskAsHttps: boolean
skipStartupAlerts: boolean
Expand Down
6 changes: 3 additions & 3 deletions frontend/projects/ui/src/app/pages/login/login.page.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ion-content class="content">
<!-- LAN HTTP -->
<ng-container *ngIf="config.isLanHttp(); else notLanHttp">
<!-- Local HTTP -->
<ng-container *ngIf="config.isLocalHttp(); else notLanHttp">
<ca-wizard></ca-wizard>
</ng-container>

<!-- not LAN HTTP -->
<!-- not Local HTTP -->
<ng-template #notLanHttp>
<div *ngIf="config.isTorHttp()" class="banner">
<ion-item color="warning">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class WifiPage {
}

async presentAlertCountry(): Promise<void> {
if (!this.config.isLan) {
if (!this.config.isLan()) {
const alert = await this.alertCtrl.create({
header: 'Cannot Complete Action',
message:
Expand Down
30 changes: 20 additions & 10 deletions frontend/projects/ui/src/app/services/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,28 @@ export class ConfigService {
return useMocks ? mocks.maskAs === 'tor' : this.hostname.endsWith('.onion')
}

isTorHttp(): boolean {
return this.isTor() && !this.isHttps()
isLocal(): boolean {
return useMocks
? mocks.maskAs === 'local'
: this.hostname.endsWith('.local')
}

isLan(): boolean {
isLocalhost(): boolean {
return useMocks
? mocks.maskAs === 'lan'
: this.hostname === 'localhost' || this.hostname.endsWith('.local')
? mocks.maskAs === 'localhost'
: this.hostname === 'localhost'
}

isLan(): boolean {
return this.isLocal() || this.isLocalhost()
}

isTorHttp(): boolean {
return this.isTor() && !this.isHttps()
}

isLanHttp(): boolean {
return this.isLan() && !this.isHttps()
isLocalHttp(): boolean {
return this.isLocal() && !this.isHttps()
}

isSecure(): boolean {
Expand All @@ -74,7 +84,7 @@ export class ConfigService {
}

launchableURL(pkg: PackageDataEntry): string {
if (this.isLan() && hasLanUi(pkg.manifest.interfaces)) {
if (this.isLan() && hasLocalUi(pkg.manifest.interfaces)) {
return `https://${lanUiAddress(pkg)}`
} else {
// leave http for services
Expand All @@ -96,7 +106,7 @@ export function hasTorUi(interfaces: Record<string, InterfaceDef>): boolean {
return !!int?.['tor-config']
}

export function hasLanUi(interfaces: Record<string, InterfaceDef>): boolean {
export function hasLocalUi(interfaces: Record<string, InterfaceDef>): boolean {
const int = getUiInterfaceValue(interfaces)
return !!int?.['lan-config']
}
Expand All @@ -118,7 +128,7 @@ export function lanUiAddress({
}

export function hasUi(interfaces: Record<string, InterfaceDef>): boolean {
return hasTorUi(interfaces) || hasLanUi(interfaces)
return hasTorUi(interfaces) || hasLocalUi(interfaces)
}

export function removeProtocol(str: string): string {
Expand Down

0 comments on commit 23f3f32

Please sign in to comment.