这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: authentication user #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
May 27, 2024
Merged

feat: authentication user #354

merged 35 commits into from
May 27, 2024

Conversation

muzanella11
Copy link
Contributor

@muzanella11 muzanella11 commented May 25, 2024

What's new:

  • Add signin page
  • Add signup page
  • Implement firebaseui and authentication process

Before feedback

Screen.Recording.2024-05-26.at.19.45.33.mov

After feedback

Screen.Recording.2024-05-27.at.14.42.13.mov

Copy link

github-actions bot commented May 26, 2024

Visit the preview URL for this PR (updated for commit efd83ba):

https://tanam-testing--pr354-issue-340-authentica-nnkwytm6.web.app

(expires Mon, 03 Jun 2024 07:44:01 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 5bbe8a1a68d9684d656bffba10008fe532204561

import {redirect} from "next/navigation";
import {SIGN_IN_ROUTE, SESSION_COOKIE_NAME} from "@/constants";

export async function createSession(token: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please link me to the React+Firebase documentation for this 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read all the documentation on nextjs, I just fixed a little of @detautama PR #346 regarding these changes. Maybe it's not perfect but I would love to read best practices from @detautama regarding these changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Session Management in Server Actions. This is the documentation about Server Actions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, server actions are used for operations on the server side (fetch data, authentication, etc), but in practice they can also be called in the client component

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @detaoddbit what happens if you remove that? I find it peculiar that next requires an additional session handling on top of Firebase Authentication.

@@ -0,0 +1,3 @@
.bg-pink {
background-color: pink;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol. Please remove this let's just use default background color inherited from global styling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol. Please remove this let's just use default background color inherited from global styling.

Will do.
This file is just for testing sass is loaded in the project or not.
This file is not loaded anywhere. Maybe in the future I'll improve the styling architecture, when I have a chance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Copy link
Contributor

@detaoddbit detaoddbit May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need create a component to declare the chidlren is client-side rendering?
We don't need this component to declare it is client-side rendering. Use use client is enough in FirebaseUi.tsx to declare it is client-side rendering. I've been test to run without this component and has no problem in FirebaseUI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, I was still injecting FirebaseUI inside the page (not in a separate component) so use client couldn't be used inside page. So I created a ClientOnly component to tell page to only display certain parts on the client side. Because the server side does not have a window context and will get an error when it is read in the server side process.
I would be happy to remove the component if it is not needed and thanks for the sharp eye

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's true, only use client has access window context. Please remove this, we already have use client feature to enable a component render in client-side 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's true, only use client has access window context. Please remove this, we already have use client feature to enable a component render in client-side 🙏🏻

But if we only add use client to the component, it will cause an error in the terminal when the server side process is running.
Screen Shot 2024-05-27 at 14 25 27

Meanwhile, if we wrap a component that only runs on the client side with the ClientOnly component, the error does not appear in the terminal when the server side process is running.
Screen Shot 2024-05-27 at 14 33 19

So which way will we take? I'm happy to hear other feedback @DennisAlund @detautama

Copy link
Contributor Author

@muzanella11 muzanella11 May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In nuxtjs they already have this component to handle components that are not carried over during the server side build process. https://nuxt.com/docs/api/components/client-only
It seems that the nextjs component that is given use client only makes the component not appear in the server side rendering process, but the files are still included in the server side build process before it is rendered using server side rendering.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes nextjs still renders or creates a cache for client components that use use client on the server, to make it trully client rendering you can make it like what @muzanella11 made or use dynamic import https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the latest version of nextjs if you use app routes it will automatically become SSR if you want to combine it with client side you can use this patterns https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns

Copy link
Member

@DennisAlund DennisAlund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as far as I can understand 🙏

Copy link

@aibnukamal aibnukamal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DennisAlund DennisAlund merged commit e2a4fa7 into next May 27, 2024
@DennisAlund DennisAlund deleted the issue/340-authentication-user branch May 27, 2024 11:11
@DennisAlund DennisAlund added this to the google-io-ext milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants