Firebase身份验证:密码必须包含大写字母 [英] Firebase Authentication: Password must contain capital letter
问题描述
我的应用程序已与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)
}
此函数将对有效的密码字符串返回true
This func will return true for valid password string
这篇关于Firebase身份验证:密码必须包含大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!