From 1df44f9edfef23ef31fac1cf483ad893ce3f49d2 Mon Sep 17 00:00:00 2001 From: Stivenjs Date: Fri, 9 May 2025 12:52:02 -0500 Subject: [PATCH 1/2] chore: update .env.example and .gitignore for environment configuration Add a new .env.example file with a default AMPLIFY_APP_ORIGIN value and modify .gitignore to exclude .env files from version control. These changes ensure consistent environment variable setup across development environments. --- .env.example | 1 + .gitignore | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..1989fe69 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +AMPLIFY_APP_ORIGIN=https://myapp.com \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1f551fa3..30130798 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,7 @@ yarn-debug.log* yarn-error.log* # local env files -.env*.local +.env # vercel .vercel From 6b9f48126e77f54e14959acb46a8d08411808e13 Mon Sep 17 00:00:00 2001 From: Stivenjs Date: Fri, 9 May 2025 14:10:31 -0500 Subject: [PATCH 2/2] refactor: remove logger and simplify auth event handling Remove the ConsoleLogger instance and replace it with direct console.log statements to simplify the code. This change reduces unnecessary complexity and improves readability while maintaining the same functionality. --- .env.example | 1 - app/(main-layout)/page.tsx | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 1989fe69..00000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -AMPLIFY_APP_ORIGIN=https://myapp.com \ No newline at end of file diff --git a/app/(main-layout)/page.tsx b/app/(main-layout)/page.tsx index 8cf9cbc7..6299ba15 100644 --- a/app/(main-layout)/page.tsx +++ b/app/(main-layout)/page.tsx @@ -18,27 +18,21 @@ Amplify.configure({ }, }) -const logger = new ConsoleLogger('HomePage') - export default function Home() { useEffect(() => { const hubListenerCancelToken = Hub.listen('auth', async ({ payload }) => { switch (payload.event) { case 'signInWithRedirect': - try { - const user = await getCurrentUser() - const userAttributes = await fetchUserAttributes() - logger.log({ user, userAttributes }) - } catch (error) { - logger.error('Error getting user session:', error) - } + const user = await getCurrentUser() + const userAttributes = await fetchUserAttributes() + console.log({ user, userAttributes }) break case 'signInWithRedirect_failure': - logger.error('Login failed with redirect:', payload.data) + console.log('error during sign in', Error) break case 'customOAuthState': - const state = payload.data - logger.log('Custom status:', state) + const state = payload.data // this will be customState provided on signInWithRedirect function + console.log(state) break } })