Customize Firebase email template [duplicate] - firebase

This question already has answers here:
Firebase authentication email customisation
(4 answers)
Closed 1 year ago.
When a user creates an account using firebase, I use the firebaseUser.sendVerficiationEmail() to send a verification link to the user. It works perfectly. However, the problem is that the email looks unprofessional and ugly. I know apps that use Firebase, such as "pic-collage", and their verification email looks pretty with their app logo on the top, and the verification link is a button.
Firebase template doesn't allow me to customize anything other than 'sender name' and 'action url'. Any help would be appreciated.

I checked and it does not seem that this is available as a ready made feature. So i am guessing the other companies you mentioned having customized verification emails have had to code them.
For that you could create a Firebase cloud functions listening for auth.onUser().user().onCreate(user), from that function you would send a custom email to the user with a link to another Firebase cloud function that one would be an https.onRequest which would complete the email verification process on it's invocation.

Related

Flutter firebase trigger email implementation

I've been trying to create a contact form for my flutter project. The contact form is composed of two steps. First, the user provides their email and then describes their issue. Once the user presses submit, I want to receive an email on my end. I've look at several packages like mailer and flutter_email_sender. However, they don't seem to offer good solutions; mailer requires that I provide the password to my email address in my code (opening up the possibility for vulnerabilities). Flutter_email_sender simply opens up an email app on the phone.
Recently I've come across the perfect solution, Firebase's new extension Trigger Email. Although the extension seems promising, I can't find any resources outlining proper implementation of Trigger Email in Flutter.
Can you please provide an example of how Trigger Email can be implemented in Flutter project?
From the documentation of the extension:
Use this extension to render and send emails that contain the information from documents added to a specified Cloud Firestore collection.
So to send an email you write a document to Cloud Firestore. For examples of writing to Cloud Firestore from Flutter, see the FlutterFire documentation for examples of this.

Email verification without having a FirebaseUser

I'm trying to send a verification email without having a firebaseUser, is it possible ?
I know i can do it with user.sendEmailVerification() method but can i do it just by giving an email from a textfield ?
Based on what I knew and what I've read from the documentation, it looks like it's not possible to do this. A Firebase user, a.k.a an user authenticated within Firebase platform is required if you want to send email verification that uses Firebase Email Vetification service.
Well, do not lose hope since there are plenty workarounds to do this. What I would do to achieve this is to use Firebase Cloud Functions to create serverless API platform. I connect Firebase Cloud Functions with Firebase Admin SDK (which also has access to other Firebase services if I am not mistaken).
I send an email using some kind of email service providers such as SendGrid to designated email address (which the app got from user's inputted email) and provide a link to verify there (in the e-mail that sent to designated email address). Then, in the cloud functions, you leverage Firebase Admin SDK to change verification status.
This approach is flexible though, as it can be used to verify a user not only with Firebase Authentication.
Hope it helps. If it's not clear for you, just comment.
Happy coding.
EDIT: After thoroughly read your question again, I realized that my answer is not fully correct. Somehow you still need a specific user to be added within Firebase Authentication database, which you would not want to do manually and let your app do so instead. Perhaps you can use Firebase Admin SDK in this matter. You can read official Firebase documentation for more information regarding Admin SDK.

Firebase - how to set custom claim from the console [duplicate]

This question already has answers here:
How to create Firebase Authentication claims?
(3 answers)
Closed 3 years ago.
In my application I use firebase authentication and Google account as credentials provider. I would like to assign roles to users. In order to do it I would like to add custom claims to the authentication token a user gets during login. And here is my problem because I don't know how to add claims to existing user from the firebase console.
There is currently no way to set custom claims for a user in the Firebase console. If you think this would be a useful addition, file a feature request for it.
In the meantime the easiest way to add a custom claim is to do so from the a terminal window/command prompt using a small Node.js script like this:
admin.auth().setCustomUserClaims(uid, {admin: true})
Also see:
How to create Firebase Authentication claims?

Firebase - How to send email verification from onCreate cloud function listener? [duplicate]

This question already has answers here:
How to send email verification after user creation with Firebase Cloud functions?
(5 answers)
Closed 4 years ago.
I'm trying to create a cloud function that will listen for when users are created, and then send an email verification to the user that was created.
I have this code:
export const verifyEmail = functions.auth.user().onCreate((user) => {
});
The problem I have here is that user gives me no way of accessing sendEmailVerification. The only way of accessing that function is via the currentUser, but since this happens in a cloud function reaction to onCreate there is no current user.
I need to somehow get a firebase.User instance instead of a firebase.UserRecord, as the onCreate gives me.
How can I solve this?
There is no way to get the client-side user from the server, nor is there a way to send verification emails through the Admin SDK.
You will either have to trigger the email from the app itself, or send your own verification email. In the latter case, you can still use the existing verification service, by generating the correct email verification link.
Also see How to send email verification after user creation with Firebase Cloud functions?, which I'll actually mark your question as a duplicate of.

Can I modify the template used for Firebase's email link-based authentication?

I'm walking through the steps described here and upon sending the verification email to myself, I get an email in my inbox from noreply#myappname.firebaseapp.com.
For other email-based auth steps, I can customize the sender name and email address directly from the Firebase console:
Am I missing something that could help me with Email Link sign-in or do I need to go through the process of modifying the SMTP settings in my app's console?
I noticed the same behavior / restriction in the Firebase console. Considering that the underlying .firebase.auth().createUserWithEmailAndPassword method could write your new user to firestore, i guess you could use firebase function to trigger a custom email via sendGrid, for example, and you could flesh out a custom workflow from there.
This article, Email via Firebase Firestore Cloud Function Triggers includes the code to trigger custom emails and could be adapted to your needs. I imagine the trick will be to get the .emailValidated property set to true. It may be as easy as switching the boolean - i don't know.
All in all, it seems like a lot of work just to get a customized validation email though. I would recommend you just stick with what they provide.

Resources