Tag: firebase authentication

Firebase在创build新用户时会注销当前用户

我正在创build一个pipe理员用户可以创build新用户的iPhone应用程序,但正如Firebase文档所述: “如果新帐户已创build,用户自动login” ,所以我正在寻找避免login的方法到新创build的用户。 有没有什么办法可以避免这种情况,而不使用新的Firebase Admin SDK(即仅Web AFAIK)?

在Firebase SDK v3中使用数据库秘密进行身份validation?

首先,我喜欢新的Firebase。 不过,我无法让我的Swift项目连接到Firebase,因为我正在使用数据库秘密来validation设备。 在Firebase SDK第3版之前,我可以使用Firebase秘密(现在是数据库机密)进行身份validation以访问我的数据库。 我能够使用下面的代码块来做到这一点: ref.authWithCustomToken("authKeyHere", withCompletionBlock: { error, authData in if error != nil { print("Login failed! \(error)") } else { print("Login to firebase succeeded! \(authData)") } }) 这对我很好,因为我只是authentication我的应用程序的用户,并没有公开整个数据库,可以这么说。 我试图用新的Firebase SDK(v3)实现同样的function。 我已经添加了必要的豆荚到我的项目,据我所见,我需要使用下面的代码来实现同样的事情: FIRApp.configure() FIRAuth.auth()?.signInWithCustomToken("authKeyHere") { (user, error) in //This signs in using the authentication secret so we can now access the database. if error […]

从匿名数据库中删除匿名用户

我正在使用Firebase数据库,并且与下一个情况有点混淆。 让我们想象我有待办事项的应用程序。 我使用标准的Firebase身份Auth系统在用户设备之间同步items 。 但在其他情况下,用户可以匿名工作而不需要同步。 步骤1: 用户启动应用程序第一次,并在AppDelegate我创build匿名用户: FIRAuth.auth()?.addStateDidChangeListener { auth, user in if let _user = user { if _user.isAnonymous { print("User logged in as anonymous. Saving uid to user defaults storage.") UserDefaults.standard.setValue(_user.uid, forKey: "uid") } else { print("User logged in with email: \(_user.email)") } } else { FIRAuth.auth()?.signInAnonymously() { (user, error) in if let […]

如何更新GoogleSign-In以使用新的Firebase控制台和API?

所以,我昨天一切正常。 然后,我login到我的Firebase控制台,并有一个横幅提示我尝试新的Firebase控制台。 “确定!听起来不错”我想。 八个小时后,我无法让Google Sign-In工作。 这是我的GIDSignInDelegate方法,它正确的引发了一切。 func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) { if (error == nil) { let authentication = user.authentication let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken) FIRAuth.auth()?.signInWithCredential(credential, completion: nil) } else { // Don't assert this error it is commonly returned as nil print("\(error.localizedDescription)") } } 问题似乎是这没有创build一个事件 FIRAuth.auth()!.addAuthStateDidChangeListener 这是在我的应用程序委托。 当使用Facebook […]

如何防止用户名在Firebase中重复注册?

我想防止重复的用户名,而signUpforms的用户input。 我已经创build了电子邮件login像下面,呃创build用户,然后用用户字典授权setValue。 但是,我使用Firebase安全设置进行堆叠,以及如何检查处理这种情况。 REF_BASE.createUser(email, password: pwd, withValueCompletionBlock: { .. REF_BASE.authUser(email, password: pwd, withCompletionBlock: { .. REF_USERS.childByAppendingPath(uid).setValue(user) 此处理总是响应错误。 REF_USERS.childByAppendingPath(uid).childByAppendingPath("username").setValue(user["username"]) { (error: NSError!, result: Firebase!) in if error != nil { print(error.localizedDescription) } else { self.REF_USERS.childByAppendingPath(uid).setValue(user) } } 这是我的安全规则,我如何修复一切可以防止重复的用户? "users": { ".read": "auth !== null", "$user": { "username": { ".read": "auth !== null", ".write": "newData.val() === auth.uid […]

Firebase身份validation(使用自定义令牌,适用于Linkedin)返回一个没有电子邮件和没有数据的用户(仅限于uid)

我正在尝试使用Linkedin和Firebaselogin。 我在我的服务器上生成自定义令牌,我有我的私钥,我使用RS256,这是我的有效载荷: "iss" : service_account_email "sub" : service_account_email "aud", "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit" "iat", Date().timeIntervalSince1970 "exp", Date().timeIntervalSince1970.advanced(by: 3600) "uid", String.randomString(length:28) 我创build令牌,将其发送回应用程序,从我做到这一点: Auth.auth().signIn(withCustomToken: token!, completion: { (user, error) in 我没有收到错误和用户回来,所以令牌是有效的。 问题是用户没有价值(没有电子邮件,没有displayName等)。 唯一的是我设置的那个uid:String.randomString(length:28) 我如何检索用户的电子邮件和其他信息? 在我的LinkedIn帐户,我有一个显示名称,电子邮件,图片等,但没有什么。 谢谢

自定义Firebase数据服务类:Swift 3

我正在寻找一种干净的方式来检索(有时保存)来自Swift中Firebase的数据。 我讨厌所有的数据库调用都写在视图控制器代码的中间。 所以我正在寻找一些自定义的数据服务类。 我发现这个教程是接近我想要的: http : //www.mobilecyberpunks.com/ ?p= 82 。 他们答应了第二部分,但我找不到第二部分,所以我猜这是从来没有。 在第二部分中,他们承诺将使用此自定义数据服务(这是整个事件中最重要的部分)来检索和保存数据。 我正在考虑一个API类(如在教程中),当我检索数据,并完成从Firebase检索,我把它保存在这个API类的数据集。 然后我会通知通知中心。 但是我不确定这是最好的做法还是做这件事的好方法。 有没有人有一个想法如何做到这一点(完成本教程我发现或以另一种方式)? 提前致谢!

如何使用Firebase创build好友列表?

我一直在研究如何使用Firebase创build好友列表系统。 到目前为止,我没有运气,并被给予不是我正在寻找的资源。 该应用程序的前提是使用用户login和身份validation创build一个帐户(已完成),然后一旦用户有一个帐户,他们可以添加在firbase用户注册的人。 这可以媲美朋友列表。 一旦用户添加了另一个用户,他们可以select创build一个只有他的朋友可以看到的post,用户可以在post旁边进行群组聊天。 问题: 不知道从哪里开始使用Firebase自定义用户login和身份validation创build好友列表 之后,只有添加到用户好友列表的人才能看到发布的内容。 PS只是寻找一些指导,从任何东西到资源/技巧

如何让应用程序等待Firebase请求完成

我希望我的方法等到Firebase请求完成 uploadSingUpInfo在Firebase请求结束之前返回,这对我来说是一个问题 – 有些方法返回nil。 static func uploadSingUpInfo(fullName:String,email:String,password:String)->String{ rootRef = FIRDatabase.database().reference() var returnVlue="not valid" FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in if (error != nil){ returnVlue=(error?.userInfo["error_name"]) as! String } else{ let newUser = [ "username": fullName ] rootRef.childByAppendingPath("User") .childByAppendingPath((user?.uid)!).setValue(newUser) NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isLogin") NSUserDefaults.standardUserDefaults().setObject(email, forKey: "email") NSUserDefaults.standardUserDefaults().setObject(user?.uid, forKey: "user_ID") print(NSUserDefaults.standardUserDefaults().objectForKey("user_ID")) returnVlue="valid" } } return returnVlue }

如何在Swift中的iOS上使用FirebaseUI进行Google身份validation?

我正在关注https://firebase.google.com/docs/auth/并希望使用FirebaseUI( https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseUI )进行身份validation。 用户界面显示成功,我可以点击“使用谷歌login”,然后完成networkingloginstream程。 该应用程序重新打开身份validationurl,但authUIfunction永远不会触发。 怎么了? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. FIRApp.configure() let authUI = FIRAuthUI.authUI()!; NSLog("setting up delegate"); authUI.delegate = self; let googleAuthUI = FIRGoogleAuthUI.init(clientID:FIRApp.defaultApp()!.options.clientID); authUI.signInProviders = [googleAuthUI!]; mSplitViewController = self.window!.rootViewController as! UISplitViewController self.window!.rootViewController = authUI.authViewController(); return true } func authUI(authUI: […]