Firebase在创建新用户时会注销当前用户 [英] Firebase logs out current user when creating a new one

查看:292
本文介绍了Firebase在创建新用户时会注销当前用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个管理员用户可以创建新用户的iPhone应用程序,但Firebase文档指出如果创建了新帐户,用户自动登录,所以我正在寻找一种方法来避免登录到新创建的用户。



有没有什么办法可以避免这种情况,而不使用新的Firebase Admin SDK(即仅Web AFAIK)?

解决方案

我在这个适用于iOS的Javascript智能解决方法。 Works完美地工作:

pre $ p $ n $ n $ n $ n $ n $ n $ n $ n $ n $ n $ n' ]。
FIROptions * secondaryAppOptions = [[FIROptions alloc] initWithContentsOfFile:plistPath];
[FIRApp configureWithName:@Secondaryoptions:secondaryAppOptions];
FIRApp * secondaryApp = [FIRApp appNamed:@Secondary];
FIRAuth * secondaryAppAuth = [FIRAuth authWithApp:secondaryApp];
$ b $ [secondaryAppAuth createUserWithEmail:user.email
password:user.password
完成:^(FIRUser * _Nullable user,NSError * _Nullable error){
[secondaryAppAuth signOut :零];
}];


I'm creating an iPhone app where an admin user can create new users, but as the Firebase documentation states "If the new account was created, the user is signed in automatically", so I'm looking for a way to avoid signing in to that newly created user.

Is there any way I can avoid this without using the new Firebase Admin SDK (that is web only AFAIK)?

解决方案

I got this Javascript smart workaround working for iOS. Works flawlessly:

NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
FIROptions *secondaryAppOptions = [[FIROptions alloc] initWithContentsOfFile:plistPath];
[FIRApp configureWithName:@"Secondary" options:secondaryAppOptions];
FIRApp *secondaryApp = [FIRApp appNamed:@"Secondary"];
FIRAuth *secondaryAppAuth = [FIRAuth authWithApp:secondaryApp];

[secondaryAppAuth createUserWithEmail:user.email
                             password:user.password
                           completion:^(FIRUser * _Nullable user, NSError * _Nullable error) {
                                [secondaryAppAuth signOut:nil];
                          }];

这篇关于Firebase在创建新用户时会注销当前用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆