fix: Bug - Login screen shows up on unreachable signal servers
Skip authorize login navigation when a signal server endpoint is offline or unreachable; gate connection and credential flows on online status only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+27
-7
@@ -5,6 +5,8 @@ import { firstValueFrom } from 'rxjs';
|
||||
import { selectCurrentUser } from '../../../../store/users/users.selectors';
|
||||
import { ServerDirectoryFacade } from '../../../server-directory';
|
||||
import { AUTH_MODE_AUTHORIZE, buildLoginReturnQueryParams } from '../../domain/logic/auth-navigation.rules';
|
||||
import { isEndpointOnlineForConnection } from '../../../server-directory/domain/logic/server-endpoint-connectivity.rules';
|
||||
import { shouldNavigateToAuthorizeSignalServer } from '../../domain/logic/signal-server-authorize.rules';
|
||||
import { SignalServerAuthService } from './signal-server-auth.service';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -25,25 +27,43 @@ export class SignalServerAuthorizeService {
|
||||
return false;
|
||||
}
|
||||
|
||||
const result = await this.signalServerAuth.ensureProvisioned(serverUrl, currentUser);
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = await this.signalServerAuth.ensureProvisioned(serverUrl, currentUser);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.kind === 'existing' || result.kind === 'provisioned') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (result.kind === 'collision') {
|
||||
await this.navigateToAuthorize(serverUrl, this.router.url);
|
||||
return false;
|
||||
}
|
||||
const endpointStatus = await this.resolveEndpointStatusForAuthorize(serverUrl);
|
||||
|
||||
if (result.kind === 'skipped' && result.reason === 'no-provision-secret') {
|
||||
if (shouldNavigateToAuthorizeSignalServer(endpointStatus, result)) {
|
||||
await this.navigateToAuthorize(serverUrl, this.router.url);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async resolveEndpointStatusForAuthorize(serverUrl: string) {
|
||||
const endpoint = this.serverDirectory.findServerByUrl(serverUrl);
|
||||
|
||||
if (!endpoint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isEndpointOnlineForConnection(endpoint.status) || endpoint.status === 'offline' || endpoint.status === 'incompatible') {
|
||||
return endpoint.status;
|
||||
}
|
||||
|
||||
await this.serverDirectory.testServer(endpoint.id);
|
||||
|
||||
return this.serverDirectory.servers().find((candidate) => candidate.id === endpoint.id)?.status ?? endpoint.status;
|
||||
}
|
||||
|
||||
async navigateToAuthorize(serverUrl: string, returnUrl: string): Promise<void> {
|
||||
const endpoint = this.serverDirectory.ensureServerEndpoint({
|
||||
name: this.buildEndpointName(serverUrl),
|
||||
|
||||
Reference in New Issue
Block a user