最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Firebase create user "manually" - Stack Overflow

programmeradmin1浏览0评论

I'm using the standard Email + Password auth-provider.

Through certain circumstances I have to create a firebase user manually. The flow would be something like calling a REST api with an defined email + generated password, and if succeeded sending a wele email to the user with his password. Something like forward user registration.

I read through their docs and couldn't find much. (the new docs don't even offer a REST API section for user management.. well and just to be clear, the new "google" styled docs, pretty much suck anyway :) ).

Is there someone who has already done something similar and can help me out?

BTW: It would also be possible to create them client side through createUserWithEmailAndPassword(), but this function does automatically reauthenticate the new user, which must not happen in my scenario. Is it possible to use createUserWithEmailAndPassword() without automatically logging in the user?

I'm using the standard Email + Password auth-provider.

Through certain circumstances I have to create a firebase user manually. The flow would be something like calling a REST api with an defined email + generated password, and if succeeded sending a wele email to the user with his password. Something like forward user registration.

I read through their docs and couldn't find much. (the new docs don't even offer a REST API section for user management.. well and just to be clear, the new "google" styled docs, pretty much suck anyway :) ).

Is there someone who has already done something similar and can help me out?

BTW: It would also be possible to create them client side through createUserWithEmailAndPassword(), but this function does automatically reauthenticate the new user, which must not happen in my scenario. Is it possible to use createUserWithEmailAndPassword() without automatically logging in the user?

Share Improve this question edited May 31, 2016 at 20:55 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked May 31, 2016 at 18:44 LukasLukas 1,3767 gold badges24 silver badges51 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can create a new Firebase App context in your client and then call createUserWithEmailAndPassword() there:

var authApp = firebase.initializeApp({
  // ...
}, 'authApp');
var detachedAuth = authApp.auth();

detachedAuth.createUserWithEmailAndPassword('[email protected]', 'asuperrandompassword');

By adding a second argument to initializeApp you create a separate context that will not trigger re-authentication upon user creation.

发布评论

评论列表(0)

  1. 暂无评论