-
Notifications
You must be signed in to change notification settings - Fork 68
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
[WIP] Firebase Auth Component #48
Conversation
This pull request introduces 9 alerts when merging 9181aff into 43d489e - view on LGTM.com new alerts:
|
This pull request introduces 7 alerts when merging 1d902eb into 43d489e - view on LGTM.com new alerts:
|
} | ||
|
||
} catch(error){ | ||
switch(error.code){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if error
includes a message
field. Directly setError
with error.message
instead of using switch-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firebase functions throw errors with a certain code. I check the error.message property. Its same as the code. In order to use custom error messages. I used switch cases.
await linkWithCredential(userCred.user,OAuthProvider.credentialFromError(diffCredError.error)); | ||
} | ||
} catch (e){ | ||
switch(e.code){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use field similar to e.message
instead of switch
.
await sendEmailVerification(userCred.user); | ||
onSignupComplete && onSignupComplete(); | ||
} catch(error){ | ||
switch(error.code){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No switch-case needed.
@abhinavkrin please highly improve code-quality, follow DRY and end new files with new-lines. |
@abhinavkrin pls resolve the trivial conflicts when you get a chance. |
projectId: process.env.FIREBASE_PROJECT_ID, | ||
clientEmail: process.env.FIREBASE_CLIENT_EMAIL, | ||
// The private key must not be accessible on the client side. | ||
privateKey: process.env.FIREBASE_PRIVATE_KEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having the user to extract these fields from the service-account file can we instead give the path to the sa file itself? Ref: https://stackoverflow.com/a/66984271/8316412
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can. But while deploying users may refrain from uploading their service-key.json file. We can set the contents of the file in an environment variable. For now, I have edited the readme.md for firebase auth and mentioned where to find the values. Waiting for your comment on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users wouldn't be required to upload their sa file to Git. Instead of scouring through the file for the variables (3 vars), it would be far easier to directly give path to the sa file (1 var), while having the user keep their file even outside the RC4Community project (the absolute path would be specified in this case).
Moreover, there is a case of having multiple sa files with different privileges. Instead of replacing the 3 env variables every time, it'll be easier for the user to just change the path to the file.
@abhinavkrin . Please:
|
@RonLek is there a difference between him squashing before commit versus us squashing when we merge? If not, perhaps we should just squash every time. |
@abhinavkrin right now, if a user just build according to instructions and does not configure firebase (set environment variables etc), then the startup will crash with a cryptic message. Can we please do a check on the required ENV VAR, and if they don't exist --- render the component into a "do nothing" sample component ? Having it build successfully and not crash, even though auth doesn't work without ENV VARs/configs, will be a significantly better developer experience. You can also log a loud errror message to the console - providing a URL to the doc on how to configure firebase. In fact, the component itself can render : "You must configure Firebase to use this component. See https://github.com/rocketchat/.... for more information" |
This pull request introduces 2 alerts when merging 5f46a00 into 8c2999d - view on LGTM.com new alerts:
|
@Sing-Li Wrote some wrapper components: |
This reverts commit 65d5d88.
* Revert "Add Firebase Auth Component (RocketChat#48)" This reverts commit 65d5d88. * revert done * remove other firebase components
This PR adds the firebase auth component to RC4Community.
Used
next-firebase-auth
Set up
.env.local
withAuthUserSSR(Page)
and useuseAuthUser()
to get user info.For more details, see https://github.com/gladly-team/next-firebase-auth
4. The
AuthUI
component handles UI for login and signup.5. To use in development env. Set,
secure: false
in cookies config ininitAuth
function in file/app/components/auth/firebase/lib/functions.js