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: oauth login #66

Merged
merged 11 commits into from
Feb 15, 2024
Merged

feat: oauth login #66

merged 11 commits into from
Feb 15, 2024

Conversation

eldu
Copy link
Contributor

@eldu eldu commented Feb 12, 2024

  • Adds Oauth, restrict to brown.edu
  • Makes add pub only available after logging in
  • refactors nav bar

After this PR goes through need to go back and edit the firebase rules to the following to ensure only logged in users can write to the firebase

    match /publications/{document=**} {
      allow read: if true;
      allow write: request.auth != null;
    }

⚠️ This PR doesn't restrict to a CCV group. Only to brown.edu

The following code would have let us see a user's groups. However, I hit a 403. It's possible that the Google Workspace administrator has not granted the necessary permissions for your application to access the groups.

// provider.addScope(
//   "https://www.googleapis.com/auth/admin.directory.group.readonly"
// );
const collectionName = 'publications';

export const handleLogin = async () => {
  try {
    await signInWithPopup(auth, provider);
    // const credential = GoogleAuthProvider.credentialFromResult(result)
    // const token = credential.accessToken
    // const user = result.user

    // const response = await fetch(`http://admin.googleapis.com/admin/directory/v1/groups?userKey=${encodeURIComponent(user.email)}`, {
    //     headers: {
    //       'Authorization': `Bearer ${token}`
    //     }
    // })

Copy link

github-actions bot commented Feb 12, 2024

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

https://ccv-pubs--pr66-feat-login-0430hb7p.web.app

(expires Thu, 22 Feb 2024 15:14:57 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f75c16b3bdd7d81b7a0b7f8d3eed826b541e7a2a

@eldu eldu changed the title Feat login feat: oauth login Feb 14, 2024
@eldu eldu self-assigned this Feb 14, 2024
@eldu eldu linked an issue Feb 14, 2024 that may be closed by this pull request
@eldu eldu marked this pull request as ready for review February 14, 2024 18:58
@eldu
Copy link
Contributor Author

eldu commented Feb 14, 2024

Opened an issue to investigate scope
#67

src/utils/firebase.ts Outdated Show resolved Hide resolved
src/styles/custom.scss Outdated Show resolved Hide resolved
Copy link

@hetd54 hetd54 left a comment

Choose a reason for hiding this comment

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

Gorgeous! Tested with brown email, and confirmed block with personal account.

@eldu eldu changed the base branch from feat-add-pub to build-update February 15, 2024 15:14
@eldu eldu merged commit 69cad1a into build-update Feb 15, 2024
2 checks passed
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.

Google Auth to add in new publications
2 participants