【问题标题】:Firebase Reset PasswordFirebase 重置密码
【发布时间】:2018-10-13 04:25:29
【问题描述】:

如果可以从应用程序更改用户密码,该文档未提供有关如何或事件的任何信息。

我们目前正在向打开 Firebase 页面的用户发送一封电子邮件,但它不会强制执行密码复杂性。

我们希望有一个屏幕,用户可以在其中重置密码。

在 FirebaseAuth.framework 中有这个方法:

/** @fn confirmPasswordResetWithCode:newPassword:completion:
@brief Resets the password given a code sent to the user outside of the app and a new password
  for the user.

@param newPassword The new password.
@param completion Optionally; a block which is invoked when the request finishes. Invoked
    asynchronously on the main thread in the future.

@remarks Possible error codes:

    + `FIRAuthErrorCodeWeakPassword` - Indicates an attempt to set a password that is
        considered too weak.
    + `FIRAuthErrorCodeOperationNotAllowed` - Indicates the administrator disabled sign
        in with the specified identity provider.
    + `FIRAuthErrorCodeExpiredActionCode` - Indicates the OOB code is expired.
    + `FIRAuthErrorCodeInvalidActionCode` - Indicates the OOB code is invalid.

@remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
**/
- (void)confirmPasswordResetWithCode:(NSString *)code
                     newPassword:(NSString *)newPassword
                      completion:(FIRConfirmPasswordResetCallback)completion;

以及验证该代码的其他方法:

/** @fn verifyPasswordResetCode:completion:
@brief Checks the validity of a verify password reset code.

@param code The password reset code to be verified.
@param completion Optionally; a block which is invoked when the request finishes. Invoked
    asynchronously on the main thread in the future.
*/
- (void)verifyPasswordResetCode:(NSString *)code
                 completion:(FIRVerifyPasswordResetCodeCallback)completion;

但似乎没有办法在 Swift 中生成该代码,也不是从 Firebase 控制台。 代码似乎在电子邮件模板%LINK% 中提供,但没有说明是否可以仅提供代码。

所以我的问题是,有没有办法在移动应用程序中设置密码重置屏幕,最好是在 iOS 应用程序中?如果是这样,我如何将该代码发送给用户?

【问题讨论】:

标签: swift firebase firebase-authentication


【解决方案1】:
Auth.auth().currentUser?.updatePassword(to: password) { (error) in
  // ...
}

对于当前登录的用户。

【讨论】:

  • 你好,想法是重置未登录用户的密码
  • 那么您必须使用电子邮件之类的第三方,否则如果他们可以在未经身份验证的情况下在应用程序中执行此操作,则您不需要安全性
  • 如果您想在应用程序中做到这一点,为什么不直接使用电话号码识别呢?或者验证电话号码,然后按照您的规则在应用内请求新密码?
  • 马克,这个想法就像 Cognito 一样,Firebase 发送的电子邮件将包含代码而不是链接,用户将输入代码,然后输入新密码。
  • Firebase 支持电子邮件、无密码登录,如果您想要的话。如果您想要一个不受支持的登录功能,那么您可能买错了产品!
猜你喜欢
  • 2013-01-14
  • 2019-05-14
  • 2018-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-18
  • 1970-01-01
  • 2018-01-15
相关资源
最近更新 更多