Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions apps/36-blocks-widget/src/app/otp/widget/widget.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,30 @@ <h2 id="oauth-consent-title" class="w-dialog-title flex-1">
[disabled]="oauthConsentLoading()"
(click)="submitOauthConsent(false)"
>
Deny
@if (oauthConsentLoading() && oauthConsentAction() === 'deny') {
<svg class="w-spinner" aria-hidden="true" fill="none" viewBox="0 0 24 24">
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
/>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8z" />
</svg>
Please wait...
} @else {
Deny
}
</button>
<button
type="button"
class="w-btn-primary"
[disabled]="oauthConsentLoading() || !oauthAuthorizeData"
(click)="submitOauthConsent(true)"
>
@if (oauthConsentLoading()) {
@if (oauthConsentLoading() && oauthConsentAction() === 'approve') {
<svg class="w-spinner" aria-hidden="true" fill="none" viewBox="0 0 24 24">
<circle
class="opacity-25"
Expand Down
14 changes: 9 additions & 5 deletions apps/36-blocks-widget/src/app/otp/widget/widget.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
private oauthProxyAuthToken: string | null = null;
public readonly showOauthConsent = signal<boolean>(false);
public readonly oauthConsentLoading = signal<boolean>(false);
/** Which consent button is in flight, so only that one shows the spinner. */
public readonly oauthConsentAction = signal<'approve' | 'deny' | null>(null);
public readonly oauthConsentError = signal<string>('');
/** Static error when GET /oauth/authorize fails validation (invalid client_id, etc.). */
public readonly showOauthError = signal<boolean>(false);
Expand Down Expand Up @@ -607,7 +609,9 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
return;
}
this.oauthConsentLoading.set(true);
this.oauthConsentAction.set(approved ? 'approve' : 'deny');
this.oauthConsentError.set('');
this.cdr.markForCheck();

const data = this.oauthAuthorizeData || {};
const scopes = data.scopes;
Expand Down Expand Up @@ -643,21 +647,21 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (res: any) => {
this.oauthConsentLoading.set(false);
const dest = res?.data?.redirect_to;
if (dest && typeof dest === 'string') {
window.location.href = dest;
if (typeof dest === 'string' && dest) {
window.location.replace(dest);
return;
}
console.error('[36Blocks] OAuth decision response missing redirect_to:', res);
this.oauthConsentLoading.set(false);
this.oauthConsentAction.set(null);
this.oauthConsentError.set('Consent succeeded but no redirect URL was returned.');
this.cdr.markForCheck();
},
error: (err) => {
console.error('[36Blocks] OAuth decision failed:', err);
this.oauthConsentLoading.set(false);
this.oauthConsentAction.set(null);
const body = err?.error ?? err;
// OAuth error body: { error, error_description } — prefer API message over HttpClient text.
const oauthError = body?.error || body?.error_description || body?.errors?.[0] || err?.errors?.[0];
this.oauthConsentError.set(
typeof oauthError === 'string' && oauthError.trim()
Expand Down
Loading