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
Comments (1)
0
mrfreeze 15 years ago