Firebase Authentication: Password must contain capital letter

后端 未结 2 716
旧时难觅i
旧时难觅i 2020-12-11 11:30

My application is linked with firebase database and authentication.

When a user creates an account, the only requirements for the password are for it to be 6 charact

相关标签:
2条回答
  • 2020-12-11 12:28

    There is no way to configure Firebase Authentication's rules for password strength.

    Also see

    • Password Requirements when making an account with firrebase
    • Firebase Password Validation allowed regex.

    You can (and should ) restrict it from your code. But you can't prevent malicious users from bypassing this by calling the API directly.

    If the password strength is a hard requirement for your app, consider implementing custom authentication. This example of custom username (instead of email) and password authentication might be helpful.

    0 讨论(0)
  • 2020-12-11 12:33

    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

    0 讨论(0)
提交回复
热议问题