Firebase 身份验证:密码必须包含大写字母 [英] Firebase Authentication: Password must contain capital letter

查看:25
本文介绍了Firebase 身份验证:密码必须包含大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序与 firebase 数据库和身份验证相关联.

My application is linked with firebase database and authentication.

当用户创建帐户时,密码的唯一要求是它是 6 个字符.无论如何我可以使密码更复杂,例如使它们具有大写字母和数字.

When a user creates an account, the only requirements for the password are for it to be 6 characters. Is there anyway I can make the password more complex, such as make them have a capital letter and a number.

我可以直接从 firebase 执行此操作,还是需要从我的代码执行此操作?

Can I do this from firebase directly, or do I need to do this from my code?

推荐答案

使用此功能.它包括范围 6-15,即最少 6 个和最多 15 个字符.一个大写字母,一个数字.

Use this function. It includes range 6-15 i.e. minimum 6 and maximum 15 characters.One Capital letter , One number respectively.

func isValidPasswordString(pwdStr:String) -> Bool {

    let pwdRegEx = "(?:(?:(?=.*?[0-9])(?=.*?[-!@#$%&*ˆ+=_])|(?:(?=.*?[0-9])|(?=.*?[A-Z])|(?=.*?[-!@#$%&*ˆ+=_])))|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[-!@#$%&*ˆ+=_]))[A-Za-z0-9-!@#$%&*ˆ+=_]{6,15}"

    let pwdTest = NSPredicate(format:"SELF MATCHES %@", pwdRegEx)
    return pwdTest.evaluate(with: pwdStr)
}

此函数将为有效的密码字符串返回真

This func will return true for valid password string

这篇关于Firebase 身份验证:密码必须包含大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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