Skip to content
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

feat: Added Oauth2 Register and Login using Appwrite #383

Closed

Conversation

thecloudcode
Copy link

@thecloudcode thecloudcode commented Jun 15, 2024

Related Issue

fixes: #284
Closes #284

Description

This issue needs a lot of description.

Initial error : "This provider is disabled. Please enable the provider from your Appwrite console to continue," indicates that the Google OAuth provider had not been enabled in the Appwrite console.

  1. Thus, the owner has to log in to his Appwrite Console and Enable Google OAuth Provider and GitHub OAuth Provider in Appwrite Console. Console -> Project -> Settings -> Auth

image

  1. Then, he/she has to go to Google Developer Console, create new project, enable OAuth Consent Screen, and create his OAuth Credentials. He will get App Id and App Secret.

  2. Paste that App Id and App Secret while enabling Github OAuth and Google OAuth and also take the URI and paste into his Google Developer Console.
    Screenshot 2024-06-15 111548

This will enable the Google and Github OAuth in Appwrite console.

This is all the owner has to do, to make things work. I have updated the necessary codes, through which the website will have proper Oauth2 Login

Screenshots & Videos

Login._.Palettegram.-.from.professionals.by.professionals.-.Google.Chrome.2024-06-15.11-27-40.mp4

The reason why you are seeing Authorization blocked and 404 error in video is because, I didn't paste the URI from Appwrite Project Auth while enabling Github and Google and added into my Google Cloud Console, because of my Credit Card Issues

But, this won't happen in your case, if you follow the steps correctly.

Follow the steps, I mentioned and it will fix this. I have updated the required codes.

Summary by CodeRabbit

  • New Features
    • Introduced Google login functionality, replacing GitHub login. Users can now log in using their Google accounts.

Copy link

vercel bot commented Jun 15, 2024

@thecloudcode is attempting to deploy a commit to the Sanchit Bajaj's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 15, 2024

Walkthrough

The primary change involves re-enabling and updating the Google login functionality in the authentication module. This update leverages Google OAuth2 for user login, aiming to enhance user experience by providing a more reliable authentication method. The change also replaces GitHub login with Google login on the login page, simplifying the authentication process.

Changes

File(s) Change Summary
src/backend/auth.api.ts Uncommented and updated the loginWithGoogle function.
src/components/pages/auth/login/index.tsx Imported loginWithGoogle and replaced loginWithGithub in the onClick handler.

Sequence Diagram(s)

sequenceDiagram
    actor User
    User ->> LoginPage: Clicks "Login with Google"
    LoginPage ->> AuthAPI: Calls `loginWithGoogle`
    AuthAPI ->> GoogleOAuth: Redirects to Google OAuth
    GoogleOAuth ->> User: Prompt User to Authenticate
    User ->> GoogleOAuth: Authenticates
    GoogleOAuth ->> AuthAPI: Returns Authorization Code
    AuthAPI ->> LoginPage: Stores Token & Redirects User
    LoginPage ->> User: User logged in successfully
Loading

Assessment against linked issues

Objective Addressed Explanation
Add OAuth2 register and login using Appwrite (#284)
Increase user experience by allowing easy login with Google (#284)
Solve session expiry issues during registration (#284) No explicit evidence that session expiry issues are solved with these changes.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added wait for reviewers gssoc GSSOC'24 Required Label labels Jun 15, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Great job, @thecloudcode! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project. Keep being the part of the community!

'We will promptly review your changes and offer feedback. Keep up the excellent work!
Kindly remember to check our Contributing Guidelines'

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
src/components/pages/auth/login/index.tsx (1)

Line range hint 194-200: Add explicit type attributes to button elements to prevent unintended form submissions.

The button elements used for OAuth2 login do not specify their type. In HTML, the default type for a button is submit, which can lead to unintended form submissions if the button is within a <form> element. To avoid this, explicitly set the type to button for these elements.

+ type="button"

Also applies to: 269-275, 280-286

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a32eeeb and 5750832.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock, !**/*.lock
Files selected for processing (2)
  • src/backend/auth.api.ts (2 hunks)
  • src/components/pages/auth/login/index.tsx (2 hunks)
Additional context used
Biome
src/backend/auth.api.ts

[error] 120-120: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.


[error] 154-154: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

src/components/pages/auth/login/index.tsx

[error] 194-200: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset


[error] 269-275: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset


[error] 280-286: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

Additional comments not posted (2)
src/components/pages/auth/login/index.tsx (2)

15-15: Ensure correct import of loginWithGoogle.

The import statement for loginWithGoogle is correctly updated to reflect its usage in the onClick handler. This change aligns with the backend changes and is necessary for the OAuth2 feature implementation.


273-273: Correctly implemented onClick handler for Google login.

The onClick handler for the Google login button is correctly set to trigger the loginWithGoogle function. This setup is essential for initiating the OAuth2 login process with Google.

src/backend/auth.api.ts Show resolved Hide resolved
src/backend/auth.api.ts Show resolved Hide resolved
@Sanchitbajaj02 Sanchitbajaj02 added 🛠 goal: fix The label is related to fixing a bug ⭐ enhancement Feature enhancement MEDIUM Difficulty Level: Medium level2 25 points and removed wait for reviewers labels Jun 18, 2024
@Sanchitbajaj02
Copy link
Owner

Hi, @thecloudcode, I have checked the end to end workflow of your changes. I concluded that the auth is fine but after authentication, user is not validated on the frontend side.
You have to handle that by following the same logic as mentioned in the email login system.

@thecloudcode
Copy link
Author

Okey I will surely @Sanchitbajaj02

Copy link

github-actions bot commented Jul 9, 2024

This PR has been automatically closed due to inactivity from the owner for 15 days.

@github-actions github-actions bot added the Stale label Jul 9, 2024
@github-actions github-actions bot closed this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Feature enhancement 🛠 goal: fix The label is related to fixing a bug gssoc GSSOC'24 Required Label level2 25 points MEDIUM Difficulty Level: Medium Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Adding Oauth2 register and login using appwrite
2 participants