I'm trying to create a demo account for my app, so that I can submit it to the iOS App Store. The app requires that your email be verified before you can use it. However, the verification emails are not coming into my demo#xxx.xxx inbox, and so I cannot verify the account. Is there any way I can manually set that firebase account as verified?
Thanks
This works as a cloud function.
I add the userid as a key to a child called force with any value and it triggers this function that authenticates the email.
you also must include
const admin = require('firebase-admin');
cloud function
exports.forceQue = functions.database.ref('/force/{uid}').onWrite((data,context) => {
if (!data.after.exists()) {
return false;
}
const uid = context.params.uid;
admin.auth().updateUser(uid, {emailVerified: true});
return true;
});
Firebase Authentication doesn't have an API to set the verification status of an email address.
The Firebase Admin SDK (which should only be run on a trusted environment, such as a machine you control) can set this flag. See this documentation section for an example.
But unless you're submitting apps on behalf of the users of your app, shouldn't the email address just be your usual (real) mail address?
if you mean adding an email on your firbase to have access as a user to the app then you can do that as per the picture
Related
With the apple user deletion policy
Apps that support account creation must also offer account deletion to give App Store users more control of the data they've shared while using your app.
I successfully refresh and revoked the token with the apple id and deleted the user from firebase.
But when deleted user tried to login again using Sign in with apple it's not showing email or username. When user sign in with apple account I am creating a user in firebase, for the first time is working good, when user deleted their account and tried to logged-in again the email is empty.
I am using the below code to retrieve email and name for the logged in user.
// Request credential for the currently signed in Apple account.
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
nonce: nonce,
);
same error with me, get email with first time signing but after that don't get email and receive null.
I fount this solution enter link description here But not the best solution, If you find a solution, please reply here.
I'm making a simple social media app. Now I'm trying to provide security while registering users.
I'd like something like. By the way, JUST code for when things go wrong, like if username exists in db, not when things go right for example: Auth.auth().crateUser()
if username already exists in db {
(dont let user register.)
} else {
(let user register)
}
if email is not valid {
(dont let user register.)
} else {
(let user register)
}
Something like that. I'm thinking maybe using alerts, etc.
Any answer is VERY appreciated...
You can tell Firebase Authentication to only allow a single user with each specific email address to register in your project. You do this by enabling the One account per email address setting in the authentication providers panel in the Firebase console.
If you mean with email validation that you want to ensure the user actually has access to the mail address that they enter, that is called email verification in Firebase. Firebase doesn't require that the user verifies their email address before they can sign in. But if your application requires that, you can tell Firebase to send a verification email from within the app. Then when the user clicks the link in that email, a property is set on their account that you can then check in your code (or in the server-side security rules if you're using the Realtime Database, Cloud Firestore, or Cloud Storage). For more on this flow, see the blog post Email Verification in Firebase Auth.
An alternative to this flow is to use Firebase's newer Email link provider. This prevents the need for the user to enter a password, instead using an email with a link for them to sign in. This automatically then also sets their email address to verified.
The use of email verification + email/password authentication doesn't quite work for services that absolutely need email verification before the user can begin using the service.
Let me explain with an example for Google sign in first.
First, the user signs into their Google account (say email is op#op.com), and authorizes your app. Then you create a credential using the tokens received through that, and exchange those tokens with Firebase to log the user into Firebase. The user needs to exist in Firebase for you to use Firebase' email verification service (because the only way to get info on whether an email is verified is to check the currentUser object in the client, so you need a logged in user to check if their email is verified. You can't call an Auth method with an email address to check if it's verified or not). So once you log the user into Firebase, you send them a verification link, and all is good. You can configure the view on your client by checking the user object for email verification. An important point to note here is that some other user who knows this user's email address cannot register using op#op.com on your service: this is because they need to sign into Google with that email to register.
Facebook is similar to Google sign-in in this regard.
However, for email/password, anyone can take someone else's email and create an account with it! And since you cannot send a verification link before the user is registered in Firebase, you're essentially letting anyone in the world "block" email addresses on your service. I was initially trying to ensure email verification before the email is registered into Firebase, but quickly realized that I need the user in Firebase to do any email verification.
Am I missing something, or is this the expected behavior? If this is really how it works, then I might just not allow email/password login in my app.
Side note: another idea I had was to do verification by sending them a 6-digit code, and maintain my own verification system in Firebase. But then I can't add any security rules to it, since any client without a logged in user would need access to it ==> potential system abuse.
Thanks in advance for attempting to read through the long explanation.
So even though an account can be created unverified, you can still block user access using security rules. The latter is what matters and controls access. Here is an example how you can do so with realtime database rules:
{
"rules": {
"users": {
"$user": {
".read": "auth.token.email_verified == true && auth.uid === $user",
".write": "auth.token.email_verified == true && auth.uid === $user"
}
}
}
}
You can also do this on your own if you are verifying the ID token on your server by parsing the token payload and inspecting the email_verified.
So even if the user account is created, unless the user is verified, they will not have access to your app/site data.
I am unable to to sucessfully to do , I followed the following steps as instructed on Firebase Docs:
Signed in use using existing auth provider(my case:facebook).
Complete the sign-in flow for the new authentication provider up to, but not including, calling one of the Auth.signInWith methods.(my case: i want to link email & password and Google OAUth). So this is the step i'm unclear about, I created a new provider using var provider = new firebase.auth.GoogleAuthProvider(); and I did not do Firebase.auth().signInWithPopup(provider) .
Then to get authcredential for google I run var credential = firebase.auth.GoogleAuthProvider.credential(
googleUser.getAuthResponse().id_token); (I get an undefined googleUser error) this error seems appropriate since I have not signed in using Google Oauth but thats what the 2nd steps states(not to signin)
And then this command to link with the current user who is on a Facebook Provider auth.currentUser.link(credential)
My understanding is that currentUser needs to be linked to my existing Provider(Facebook). It seems that credential variable for google is never computed. Anyone with a functional code example would really help.
If you want to manually link a google and email/pass account to existing facebook only firebase user, you can do the following:
First, the user should be signed in to Facebook.
Link the google user:
var provider = new firebase.auth.GoogleAuthProvider();
auth.currentUser.linkWithPopup(provider);
Then link the email/pass account:
auth.currentUser.linkWithCredential(firebase.auth.EmailAuthProvider.credential(auth.currentUser.email, 'password'))
All these accounts to be linked must be new and not already linked.
#bojeil I have read your question and I found the way to log in both Google and Facebook logins having the same email account. First, in the Firebase, you need to allow
"Multiple accounts per email address"
Allow multiple accounts per email address
Now you can log in with both Facebook having "xyz#gmail.com" & Google having the same email name as "xyz#gmail.com".But you will encounter the email as "null" for the second login having the same email. You can get over the null problem by using the below snippet.
Just use this snippet in on success task from the firebase:
Map profile = task.getResult().getAdditionalUserInfo().getProfile();
Object email = profile.get("email"); /// Obtaining the email from the use though we use same email form facebook and Google log in accounts.
By this way, you can log in into both Facebook and Google logins using the same email.
I hope you got your doubt cleared with this info. Can you please get back to me if this suits your question?.
Thank you.
Situation:
User A registers an account in our application and logs in.
For what ever reason logs out.
Logs in to the application again using Facebook social sign on with an account that has the same email associated with it as the
original registration had.
A second account is created for this sign on and 2 accounts exist in the system.
How can I merge these accounts into a single account during the social sign on (by querying for the existence of that email) automatically or with User Collection Business Hooks (if with business hooks, can you please provide an example of how I would do this as documentation online is unclear for this specific purpose).
Notes:
Kinvey backend
Phonegap with facebook plugin
Jquery mobile
Wish to merge accounts or find existing account and add social identity to it during sign on
Assume I cannot delete users
Preferably achieve this step with a PreSave Kinvey Business Logic Hook
Cheers,
I managed to create my own custom end point to basically achieve user merging.
If a user exists with a kinvey account, then tries to log in using facebook with an email address matching a kinvey user, I used the following end point code to add a social identity to the existing user before attempting to log in using that user (This function only worked because we maintain a guest login for users not logged in to the system).
Hope this helps some one.
function onRequest(request, response, modules) {
var users = modules.collectionAccess.collection('user');
var social = request.body.social;
users.findAndModify({"username":request.body.email},{$set:{"_socialIdentity":social}},
function(err,result){
if(err){
response.error(err);
response.complete();
}else{
if(!result._id){
response.body = {message:"No User Found Matching This Email"};
response.complete();
}else{
response.body = {message:"User Was Hopefully Updated"};
response.complete();
}
}
});
}