Skip to content
Merged

Stage #651

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
7 changes: 3 additions & 4 deletions apps/36-blocks-widget/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { BaseComponent } from '@proxy/ui/base-component';
import { WidgetTheme, PublicScriptType, WidgetConfig, PROXY_DOM_ID } from '@proxy/constant';
import { WidgetThemeService } from './otp/service/widget-theme.service';

const REFERENCE_ID = '4512365b177668815069e61c1692def';
const REFERENCE_ID = '4512365o17835822266a4f4e12e0cd1';
const THEME: WidgetTheme = WidgetTheme.System;
const TYPE: PublicScriptType = PublicScriptType.UserProfile;
const TYPE: PublicScriptType = PublicScriptType.Authorization;
const OPEN_EDIT_PROFILE = true;
const AUTH_TOKEN =
'VnNwWTNwWEZYV2VicU1mWElaNjU2S08vZS94N3JxVVhCcUt2RU9KVy9JZ1BlWEJPczlTeU1ZNlowRVRrbVFPVGNIT09XNjJRelB3VXg0V0kyR1NGSEc3Q1VjRTNKVGJrVnk4WWMwdWJWYTBrUGJYYSs4UXpqdVkwOGVnOHI4Sk1DRW5lZDdxODFTTk14SC9UczVFTGJReWZyTmg4NHRKZVBOTFRPdzlMS2xOb29IcmZZWkhTd0FwUnBoRTY5TjJJOU1VbUdKeEhRdzRhTHFlSFpxaTByQT09';
const AUTH_TOKEN = '';

@Component({
selector: 'proxy-root',
Expand Down
5 changes: 4 additions & 1 deletion apps/36-blocks-widget/src/app/otp/widget/widget.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,10 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
this.renderer.appendChild(paragraph, link);
this.renderer.appendChild(element, paragraph);

// Powered by footer
// Powered by footer — hidden when branding is removed (ui_preferences.remove_branding)
if (selectWidgetTheme?.ui_preferences?.remove_branding) {
return;
}
const poweredBy: HTMLParagraphElement = this.renderer.createElement('a');
poweredBy.setAttribute('href', 'https://36blocks.com');
poweredBy.setAttribute('target', '_blank');
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export class CreateFeatureComponent extends BaseComponent implements OnDestroy,
title: new FormControl<string>('Sign in to your account', []),
sign_up_button_text: new FormControl<string>('Create an account', [Validators.required]),
create_account_link: new FormControl<boolean>(true, []),
remove_branding: new FormControl<boolean>(false, []),
theme: new FormControl<string>('system', []),
version: new FormControl<string>('v2', []),
}),
Expand Down Expand Up @@ -459,6 +460,7 @@ export class CreateFeatureComponent extends BaseComponent implements OnDestroy,
sign_up_button_text: feature.ui_preferences?.sign_up_button_text ?? 'Create an account',
icons: feature.ui_preferences?.icons ?? false,
create_account_link: feature.block_registration ?? true,
remove_branding: feature.ui_preferences?.remove_branding ?? false,
theme: feature.ui_preferences?.theme || 'system',
version: feature.ui_preferences?.version || 'v1',
},
Expand Down
42 changes: 21 additions & 21 deletions apps/36-blocks/src/app/panel/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,27 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy
}
});

this.clientSettings$.pipe(takeUntil(this.destroy$)).subscribe((clientSettings) => {
if (clientSettings?.client) {
this.logInData$.pipe(take(1)).subscribe((existingLoginData) => {
if (!existingLoginData) {
this.store.dispatch(
logInActions.authenticatedAction({
response: {
uid: String(clientSettings.client.id),
displayName: clientSettings.client.name,
email: clientSettings.client.email,
phoneNumber: clientSettings.client.mobile ?? null,
photoURL: null,
emailVerified: false,
jwtToken: this.authService.getTokenSync(),
},
})
);
}
});
}
});
// this.clientSettings$.pipe(takeUntil(this.destroy$)).subscribe((clientSettings) => {
// if (clientSettings?.client) {
// this.logInData$.pipe(take(1)).subscribe((existingLoginData) => {
// if (!existingLoginData) {
// this.store.dispatch(
// logInActions.authenticatedAction({
// response: {
// uid: String(clientSettings.client.id),
// displayName: clientSettings.client.name,
// email: clientSettings.client.email,
// phoneNumber: clientSettings.client.mobile ?? null,
// photoURL: null,
// emailVerified: false,
// jwtToken: this.authService.getTokenSync(),
// },
// })
// );
// }
// });
// }
// });

combineLatest([this.logInData$, this.clientSettings$]).subscribe(([loginData, clientSettings]) => {
if (loginData && clientSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,85 @@
</div>
}

<!-- ── Settings Tab ── -->
<!-- ── Testing Users Tab ── -->
@if (selectedSectionIndex === 3) {
<div class="flex flex-wrap items-center justify-between gap-4 mb-4">
<div class="grow">
<p class="mat-body-2 font-medium m-0">Test Users</p>
<p class="text-grey text-xs m-0">
Users who log in with a matching email or mobile are treated as test users. On logout,
their account (and any organization where they are the only member) is deleted.
</p>
</div>
<button
matButton="filled"
class="mat-btn-xs"
(click)="addTestUser()"
[disabled]="testIdentities.length >= maxTestIdentities"
>
<mat-icon class="mat-icon-prefix mat-icon-18 material-icons-outlined">add</mat-icon>
Add Test User
</button>
</div>

<div class="table-scroll">
<table mat-table [dataSource]="testIdentitiesDataSource" class="default-table responsive-table">
<!-- Email Column -->
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef>Email</th>
<td mat-cell *matCellDef="let element" data-label="Email">
{{ element.email || '—' }}
</td>
</ng-container>

<!-- Mobile Column -->
<ng-container matColumnDef="mobile">
<th mat-header-cell *matHeaderCellDef>Mobile</th>
<td mat-cell *matCellDef="let element" data-label="Mobile">
{{ element.mobile || '—' }}
</td>
</ng-container>

<!-- Actions Column -->
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef></th>
<td mat-cell *matCellDef="let element" data-label="Actions">
<div class="actions flex gap-3 justify-end">
<button
matButton="outlined"
(click)="removeTestUser(element)"
class="mat-btn-md"
>
<mat-icon class="material-icons-outlined mat-icon-18 mat-icon-prefix"
>delete</mat-icon
>
Remove
</button>
</div>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="testIdentitiesDisplayedColumns; sticky: true"></tr>
<tr
mat-row
*matRowDef="let row; columns: testIdentitiesDisplayedColumns"
class="hover-action"
></tr>

<tr *matNoDataRow>
<td class="mat-cell border-0" [attr.colspan]="testIdentitiesDisplayedColumns.length">
<proxy-no-record-found
[title]="'test users'"
[showBtn]="false"
></proxy-no-record-found>
</td>
</tr>
</table>
</div>
}

<!-- ── Settings Tab ── -->
@if (selectedSectionIndex === 4) {
<div class="w-full">
<p class="mat-body-2 font-medium mb-6">Default Roles</p>
<form [formGroup]="defaultRolesForm">
Expand Down Expand Up @@ -400,3 +477,44 @@ <h2 matDialogTitle>{{ isEditPermissionMode ? 'Edit Permission' : 'Add Permission
</button>
</mat-dialog-actions>
</ng-template>

<!-- Add Test User Dialog Template -->
<ng-template #addTestUserDialogTemplate>
<h2 matDialogTitle>Add Test User</h2>
<mat-dialog-content>
<form [formGroup]="dialogTestUserForm" class="flex flex-col gap-1">
<mat-form-field appearance="outline" class="w-full mt-2">
<mat-label>Email</mat-label>
<input matInput type="email" formControlName="email" placeholder="user@example.com" />
@if (dialogTestUserForm.get('email')?.hasError('email')) {
<mat-error>Enter a valid email</mat-error>
}
</mat-form-field>

<mat-form-field appearance="outline" class="w-full">
<mat-label>Mobile</mat-label>
<input matInput formControlName="mobile" placeholder="+919876543210" />
<mat-hint>Include the country code with a leading + (e.g. +919876543210)</mat-hint>
@if (dialogTestUserForm.get('mobile')?.hasError('maxlength')) {
<mat-error>Mobile must be 20 characters or fewer</mat-error>
}
</mat-form-field>

@if (
dialogTestUserForm.hasError('atLeastOneContact') &&
(dialogTestUserForm.dirty || dialogTestUserForm.touched)
) {
<p class="text-red-500 text-xs mt-1 mb-0">Provide at least one of email or mobile.</p>
}

<p class="text-grey text-xs mt-2 mb-0">
Warning: adding a real user's email or mobile will delete their account (and any organization where they
are the only member) on their next logout.
</p>
</form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button matButton (click)="closeTestUserDialog()">Close</button>
<button matButton="filled" (click)="submitTestUserDialog()" [disabled]="dialogTestUserForm.invalid">Add</button>
</mat-dialog-actions>
</ng-template>
Loading
Loading