Skip to content
Merged

Stage #628

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
49 changes: 24 additions & 25 deletions apps/36-blocks-widget/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ 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 = '4512365o177529298869d0d23cc0453';
const REFERENCE_ID = '4512365b177668815069e61c1692def';
const THEME: WidgetTheme = WidgetTheme.System;
const TYPE: PublicScriptType = PublicScriptType.UserManagement;
const AUTH_TOKEN =
'cmtQRzJ4KzBwajJ4QS9vOVFMR1ZmamxLaGFGazlRcnpiOUM4NFhPWXdDZkRDV293T0VWV0tFV1NFbVlmVTE2WkRsUHFVUk5ybHREUHk2VjdLM2FDNFcybDF6MjJnOFY5MjNZTVdQVVVWVWVJTDJHakNHNFRadVJwWDRmUVZrakVCNVVTdGZhSVRadmlYVEZTS1FJZTl2cSsycUpaQVpCZ2JyYmoxVVBPYTI0bXpBLy9lUkozTTJTVU9XWUl6VjI4a3ZyVGlOajVmczkvK0VNc3hXa3Mzdz09';
const TYPE: PublicScriptType = PublicScriptType.Authorization;
const AUTH_TOKEN = '';

@Component({
selector: 'proxy-root',
Expand Down Expand Up @@ -62,30 +61,30 @@ export class AppComponent extends BaseComponent implements OnInit, OnDestroy {
console.log('Failure reason:', error);
},
};
if (TYPE) {
widgetConfig['type'] = TYPE;
// if (TYPE) {
// widgetConfig['type'] = TYPE;

if (TYPE === PublicScriptType.Authorization) {
// Optional: Path to redirect after login (e.g., '/login') only used get proxy_auth_token in admin panel while preview
// widgetConfig['redirect_path'] = '/login';
// Used to show Company details in the signup/registration form, default is true
// showCompanyDetails: false,
} else {
widgetConfig['authToken'] = AUTH_TOKEN;
// if (TYPE === PublicScriptType.Authorization) {
// // Optional: Path to redirect after login (e.g., '/login') only used get proxy_auth_token in admin panel while preview
// // widgetConfig['redirect_path'] = '/login';
// // Used to show Company details in the signup/registration form, default is true
// // showCompanyDetails: false,
// } else {
// widgetConfig['authToken'] = AUTH_TOKEN;

if (TYPE === PublicScriptType.UserManagement) {
// Enables the Role & Permission tab in the User Management widget
widgetConfig['isRolePermission'] = false;
}
// if (TYPE === PublicScriptType.UserManagement) {
// // Enables the Role & Permission tab in the User Management widget
// widgetConfig['isRolePermission'] = false;
// }

// Note: Currently Subscription widget is not in use.
if (TYPE === PublicScriptType.Subscription) {
// Use in Subscription widget to redirect
// loginRedirectUrl: 'https://www.google.com',
// widgetConfig['isPreview'] = true;
}
}
}
// // Note: Currently Subscription widget is not in use.
// if (TYPE === PublicScriptType.Subscription) {
// // Use in Subscription widget to redirect
// // loginRedirectUrl: 'https://www.google.com',
// // widgetConfig['isPreview'] = true;
// }
// }
// }
if (THEME) {
widgetConfig['theme'] = THEME;
}
Expand Down
7 changes: 3 additions & 4 deletions apps/36-blocks-widget/src/app/init-verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ function validateWidgetConfig(config: any): void {

if (!window.initVerification) {
window['initVerification'] = (config: any) => {
// Validate widget config and show error in console
validateWidgetConfig(config);

// In case of no type, set default to Authorization
// Default before validation: referenceId-only / legacy embeds omit `type` (authorization login widget).
if (!config?.type) {
config = { ...config, type: PublicScriptType.Authorization };
}
validateWidgetConfig(config);

const initFn = () => {
const urlParams = new URLSearchParams(window.location.search);
const isRegisterFormOnlyFromParams = urlParams.get('isRegisterFormOnly') === 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,17 @@ <h2 class="text-base font-semibold text-gray-900 dark:text-white">
}
Login
</button>
<p class="text-center text-xs text-gray-500 dark:text-gray-400">
New User?
<a
href="javascript:void(0)"
(click)="showRegistration()"
class="font-medium text-indigo-600 dark:text-indigo-400 hover:underline cursor-pointer"
>Create Account</a
>
</p>
@if (!isCreateAccountTextAppended()) {
<p class="text-center text-xs text-gray-500 dark:text-gray-400">
New User?
<a
href="javascript:void(0)"
(click)="showRegistration()"
class="font-medium text-indigo-600 dark:text-indigo-400 hover:underline cursor-pointer"
>Create Account</a
>
</p>
}
</div>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { NgHcaptchaModule } from 'ng-hcaptcha';
})
export class LoginComponent extends BaseComponent implements OnInit, OnDestroy {
public loginServiceData = input<any>();
public isCreateAccountTextAppended = input<boolean>(false);
public theme = input<string>();
protected readonly WidgetTheme = WidgetTheme;
private readonly themeService = inject(WidgetThemeService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ <h2 class="w-dialog-title">{{ showRegistration() ? 'Register' : 'Login' }}</h2>
<proxy-login
[loginServiceData]="loginWidgetData"
[theme]="theme"
[isCreateAccountTextAppended]="isCreateAccountTextAppended"
(togglePopUp)="closeOverlayDialog()"
(closePopUp)="closeOverlayDialog()"
(openPopUp)="setShowRegistrationFromLogin($event)"
Expand Down
8 changes: 4 additions & 4 deletions apps/36-blocks-widget/src/app/otp/widget/widget.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
this.version = theme?.ui_preferences?.version || 'v1';
this.input_fields = theme?.ui_preferences?.input_fields || 'top';
this.show_social_login_icons = theme?.ui_preferences?.icons || false;
this.isCreateAccountTextAppended = theme?.ui_preferences?.create_account_link || false;
this.isCreateAccountTextAppended = theme?.ui_preferences?.block_registration || false;
this.dialogBorderRadius = this.getBorderRadiusCssValue(theme?.ui_preferences?.border_radius);
});
if (this.type === PublicScriptType.Subscription) {
Expand Down Expand Up @@ -873,7 +873,7 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
loginButton.disabled = false;
loginButton.textContent = originalText;

if (error?.status === 403) {
if (error?.status === 403 && this.isCreateAccountTextAppended) {
this.setShowRegistration(true, username);
resetHCaptcha();
return;
Expand Down Expand Up @@ -1441,7 +1441,7 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
}

private appendCreateAccountText(element): void {
if (!this.isCreateAccountTextAppended) {
if (this.isCreateAccountTextAppended) {
return;
}
const existingCreateAccountText = element.querySelector('p[data-create-account="true"]');
Expand Down Expand Up @@ -1546,7 +1546,7 @@ export class ProxyAuthWidgetComponent extends BaseComponent implements OnInit, O
}
},
(error: HttpErrorResponse) => {
if (error?.status === 403) {
if (error?.status === 403 && this.isCreateAccountTextAppended) {
this.setShowRegistration(true);
this.show.set(true);
this.registrationViaLogin = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ <h2 class="mat-h2 font-semibold text-light-gray mb-0" [style.color]="getEffectiv
}

<!-- Are you a new user - always at bottom -->
@if (featureForm.get('brandingDetails.create_account_link').value) {
@if (!featureForm.get('brandingDetails.create_account_link').value) {
<p class="mat-body-2 text-center font-14" [style.color]="getEffectivePrimaryColor()">
Are you a new user?
<a class="text-link" href="#">{{
Expand Down Expand Up @@ -1120,7 +1120,7 @@ <h2 class="mat-h2 font-semibold text-light-gray mb-0" [style.color]="getEffectiv
}
"
></ng-container>
@if (isEditMode && featureForm.get('primaryDetails.feature_id')?.value === 1) {
<!-- @if (isEditMode && featureForm.get('primaryDetails.feature_id')?.value === 1) {
<div class="flex items-center justify-between gap-3 py-3 px-3 my-3 rounded-lg">
<div class="flex flex-col gap-0.5">
<span class="mat-body-2 font-medium">Block new user sign-ups</span>
Expand All @@ -1133,7 +1133,7 @@ <h2 class="mat-h2 font-semibold text-light-gray mb-0" [style.color]="getEffectiv
color="primary"
></mat-slide-toggle>
</div>
}
} -->
</div>
</div>

Expand Down Expand Up @@ -2213,7 +2213,7 @@ <h5 class="mat-h5 my-0">Taxes</h5>
</div>
@if (isEditMode) {
<div class="flex items-center justify-between gap-3 px-4 py-3">
<span class="mat-body-2">Show Create Account for new user</span>
<span class="mat-body-2">Block new user sign-ups</span>
<mat-slide-toggle
[formControl]="featureForm.get('brandingDetails.create_account_link')"
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export class CreateFeatureComponent extends BaseComponent implements OnDestroy,
title: feature.ui_preferences?.title,
sign_up_button_text: feature.ui_preferences?.sign_up_button_text ?? 'Create an account',
icons: feature.ui_preferences?.icons ?? false,
create_account_link: feature.ui_preferences?.create_account_link ?? true,
create_account_link: feature.block_registration ?? true,
theme: feature.ui_preferences?.theme || 'system',
version: feature.ui_preferences?.version || 'v1',
},
Expand Down Expand Up @@ -882,6 +882,7 @@ export class CreateFeatureComponent extends BaseComponent implements OnDestroy,
logo_url:
this.logoInputMode === 'file' ? this.logoUrl() : brandingDetailsForm.value.logo_url,
},
block_registration: brandingDetailsForm.value.create_account_link || false,
};
} else {
brandingDetailsForm.markAllAsTouched();
Expand Down
5 changes: 4 additions & 1 deletion apps/36-blocks/src/app/panel/layout/layout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
</button>
</div>
<!-- Proxy Sidenav::START -->
<proxy-main-left-side-nav class="mat-drawer-nav proxy-left-menu flex-1"></proxy-main-left-side-nav>
<proxy-main-left-side-nav
[isSideNavOpen]="!sideNavService.isSideNavOpen()"
class="mat-drawer-nav proxy-left-menu flex-1"
></proxy-main-left-side-nav>
<!-- Proxy Sidenav::END -->
@if (logInData$ | async; as user) {
<proxy-sidebar-user-menu
Expand Down
Loading