def createUser(db, email, password, firstName=None, lastName=None, phone=None, imageId=None, locationId=None, affiliation=None, isAdmin=False): userId = None key = util.random_string(10) encrypted_password, salt = makePassword(password) try: userId = db.insert('user', user_key=key, email=email, password=encrypted_password, salt=salt, phone=phone, first_name=firstName, last_name=lastName, affiliation=affiliation, image_id=imageId, location_id=locationId, created_datetime=None) except Exception, e: log.info("*** problem creating user") log.error(e)
def resetPassword(db, userId): forgetfulUser = User(db, userId) newPassword = util.random_string(10) if (forgetfulUser.updatePassword(newPassword)): return mMessaging.emailTempPassword(forgetfulUser.email, newPassword) else: return False
def createUser(db, email, password, firstName = None, lastName = None, phone = None, imageId = None, locationId = None, affiliation = None, isAdmin = False): userId = None key = util.random_string(10) encrypted_password, salt = makePassword(password) try: userId = db.insert('user', user_key=key, email=email, password=encrypted_password, salt=salt, phone=phone, first_name=firstName, last_name=lastName, affiliation=affiliation, image_id=imageId, location_id=locationId, created_datetime=None) except Exception, e: log.info("*** problem creating user") log.error(e)
def test_random_string(self): self.assertEqual(len(util.random_string(12)), 12) self.assertEqual(len(re.findall("^[A-Za-z0-9]{12}$", util.random_string(12))), 1)
def makePassword(password, salt = None): if (not salt): salt = util.random_string(10) hashed_password = hashlib.md5(password + salt).hexdigest() return [hashed_password, salt]
def makePassword(password, salt=None): if (not salt): salt = util.random_string(10) hashed_password = hashlib.md5(password + salt).hexdigest() return [hashed_password, salt]