If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

This ensures that the random password has one upper, one lower, one number, one special character and is longer than 8 characters. This should cover any complexity requirement. In your model, create a cla-- that inherits from Auth then simply override the random_password function:

from gluon.tools import *
class MyAuth(Auth):    
    def random_password(self):
        import string
        import random
        password = ''
        specials=r'!#$*?'         
        for i in range(0,3):
            password += random.choice(string.lowercase)
            password += random.choice(string.uppercase)
            password += random.choice(string.digits)
            password += random.choice(specials)            
        return ''.join(random.sample(password,len(password)))

auth=MyAuth(globals(),db)

Depricated

Related slices

Comments (1)


Hosting graciously provided by:
Python Anywhere