From 2c746437c9be1bebc143cb2acdba22fbb8e01c95 Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala <60499540+chiragchhatrala@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:11:11 +0530 Subject: [PATCH] Re-login modal (#717) * Implement quick login/register flow with global event handling - Add QuickRegister component with improved modal management - Integrate quick login/register with app store state - Implement custom event handling for login/registration flow - Update OAuth callback to support quick login in popup windows - Refactor authentication-related components to use global events * Refactor authentication flow with centralized useAuth composable - Create new useAuth composable to centralize login, registration, and social login logic - Simplify authentication methods in LoginForm and RegisterForm - Add event-based login/registration flow with quick login support - Remove redundant API calls and consolidate authentication processes - Improve error handling and analytics tracking for authentication events * Enhance QuickRegister and RegisterForm components with unauthorized error handling - Add closeable functionality to modals based on unauthorized error state - Implement logout button in QuickRegister for unauthorized users - Reset unauthorized error state on component unmount - Update styling for "OR" text in RegisterForm for consistency - Set unauthorized error flag in app store upon 401 response in API calls * Refactor Authentication Flow and Remove Unused Callback Views - Deleted unused callback views for Notion and OAuth to streamline the codebase. - Updated QuickRegister and LoginForm components to remove the after-login event emission, replacing it with a window message system for better communication between components. - Enhanced the RegisterForm and other components to utilize the new window message system for handling login completion, improving reliability and maintainability. - Added a verifyAuthentication method in the useAuth composable to ensure user data is loaded correctly after social logins, including retry logic for fetching user data. These changes aim to simplify the authentication process and improve the overall user experience by ensuring a more robust handling of login events. * Add eslint-disable comment to useWindowMessage composable for linting control * Refactor QuickRegister.vue for improved template structure and clarity - Adjusted the rendering of horizontal dividers and the "or" text for better semantic HTML. - Added a compact-header prop to the modal for enhanced layout control. These changes aim to enhance the readability and maintainability of the QuickRegister component. --------- Co-authored-by: Julien Nahum --- api/resources/views/notion/callback.blade.php | 12 -- api/resources/views/oauth/callback.blade.php | 12 -- .../views/oauth/emailTaken.blade.php | 5 - client/app.vue | 1 + .../form-components/FormCustomSeo.vue | 2 +- .../pages/auth/components/LoginForm.vue | 61 +++--- .../pages/auth/components/QuickRegister.vue | 157 +++++++++++---- .../pages/auth/components/RegisterForm.vue | 75 +++---- client/composables/useAuth.js | 165 +++++++++++++++ client/composables/useOpnApi.js | 3 +- client/composables/useWindowMessage.js | 188 ++++++++++++++++++ client/pages/forms/create/guest.vue | 21 +- client/pages/oauth/callback.vue | 117 +++++------ client/stores/app.js | 5 +- client/stores/oauth_providers.js | 2 +- 15 files changed, 602 insertions(+), 224 deletions(-) delete mode 100644 api/resources/views/notion/callback.blade.php delete mode 100644 api/resources/views/oauth/callback.blade.php delete mode 100644 api/resources/views/oauth/emailTaken.blade.php create mode 100644 client/composables/useAuth.js create mode 100644 client/composables/useWindowMessage.js diff --git a/api/resources/views/notion/callback.blade.php b/api/resources/views/notion/callback.blade.php deleted file mode 100644 index 6a7df31f..00000000 --- a/api/resources/views/notion/callback.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - {{ config('app.name') }} - - - - - diff --git a/api/resources/views/oauth/callback.blade.php b/api/resources/views/oauth/callback.blade.php deleted file mode 100644 index 45a30b58..00000000 --- a/api/resources/views/oauth/callback.blade.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - {{ config('app.name') }} - - - - - diff --git a/api/resources/views/oauth/emailTaken.blade.php b/api/resources/views/oauth/emailTaken.blade.php deleted file mode 100644 index af899b29..00000000 --- a/api/resources/views/oauth/emailTaken.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('errors.layout') - -@section('title', 'Login Error') - -@section('message', 'Email already taken.') diff --git a/client/app.vue b/client/app.vue index bdd3691f..7cc46c24 100644 --- a/client/app.vue +++ b/client/app.vue @@ -50,6 +50,7 @@ + diff --git a/client/components/open/forms/components/form-components/FormCustomSeo.vue b/client/components/open/forms/components/form-components/FormCustomSeo.vue index e62205d5..f55eee42 100644 --- a/client/components/open/forms/components/form-components/FormCustomSeo.vue +++ b/client/components/open/forms/components/form-components/FormCustomSeo.vue @@ -114,7 +114,7 @@ export default { this.form.seo_meta[keyname] = null }) - if (this.form.custom_domain && !this.workspace.custom_domains.find((item) => { return item === this.form.custom_domain })) { + if (this.form.custom_domain && this.workspace?.custom_domains && !this.workspace.custom_domains.find((item) => { return item === this.form.custom_domain })) { this.form.custom_domain = null } } diff --git a/client/components/pages/auth/components/LoginForm.vue b/client/components/pages/auth/components/LoginForm.vue index 0014ddb9..004211d6 100644 --- a/client/components/pages/auth/components/LoginForm.vue +++ b/client/components/pages/auth/components/LoginForm.vue @@ -97,8 +97,7 @@ diff --git a/client/components/pages/auth/components/RegisterForm.vue b/client/components/pages/auth/components/RegisterForm.vue index e5ce1edf..89d3c4ce 100644 --- a/client/components/pages/auth/components/RegisterForm.vue +++ b/client/components/pages/auth/components/RegisterForm.vue @@ -104,8 +104,8 @@