gpt4 book ai didi

swift - Firebase 重设密码

转载 作者:行者123 更新时间:2023-11-28 07:49:05 24 4
gpt4 key购买 nike

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

我们目前正在向打开 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 应用程序)中设置重设密码屏幕?如果是,我该如何将该代码发送给用户?

最佳答案

Auth.auth().currentUser?.updatePassword(to: password) { (error) in
// ...
}

对于当前登录的用户。

关于swift - Firebase 重设密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50145161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com