def insert_user(data): user_rec = dict( FIRSTNAME=data.first_name, LASTNAME=data.last_name, LOGINID=data.username, EMAIL=data.email, PHONE=data.phone, PASSWORD=gen_password(), DTUPD=now, DTADD=now, STATUS="A", ) db = system.database table = db.table("dz_users", "USERID") new_id = table.insert(user_rec) # set user password user = User(data.username) user.set_password(data.password) # make sure new users don't accidentally get access db("delete from dz_members where userid=%s", new_id) # add default group add_user(user.username, "users") return new_id
def reset_password(token, password, confirm): if not valid_token(token): return Page('expired') elif not valid_new_password(password): error('Invalid password ({})'.format(valid_new_password.msg)) elif password <> confirm: error('Passwords do not match') else: user = user_by_token(token) if not user: error('Invalid request') else: user = User(user['LOGINID']) user.set_password(password) rec = ForgotToken.find(token=token)[0] rec.expiry = time.time() rec.put() return home('complete')
def reset_password(token,password,confirm): if not valid_token(token): return Page('expired') elif not valid_new_password(password): error('Invalid password ({})'.format(valid_new_password.msg)) elif password <> confirm: error('Passwords do not match') else: user = user_by_token(token) if not user: error('Invalid request') else: user = User(user['LOGINID']) user.set_password(password) rec = ForgotToken.find(token=token)[0] rec.expiry = time.time() rec.put() return home('complete')
def insert(cls, form): values = form.evaluate() username = values['USERNAME'].lower() password = gen_password() values['FIRSTNAME'] = values['FIRST_NAME'] values['LASTNAME'] = values['LAST_NAME'] values['LOGINID'] = username values['PASSWORD'] = '' values['DTUPD'] = values['DTADD'] = datetime.datetime.now() values['STATUS'] = 'A' users = db.table('dz_users', 'USERID') id = users.insert(values) db('delete from dz_members where userid=%s', id) # make sure new users have no memberships add_user(values['LOGINID'], 'users') new_user = ZoomUser(username) new_user.set_password(password) msg = '<a href="/users/%s">%s</a> added new user <a href="/users/%s">%s</a>' logger.activity( 'users', msg % (user.id, user.username, new_user.id, new_user.username)) audit('created user account', new_user.username) if values['SEND_INVITATION'] == True: recipients = [values['EMAIL']] tpl = load('welcome.md') t = dict( first_name=values['FIRST_NAME'], username=username, password=password, site_name=site_name(), site_url=site_url(), admin_email='*****@*****.**', owner_name=owner_name(), ) body = markdown(viewfill(tpl, t.get)) subject = 'Welcome - ' + site_name() send(recipients, subject, body) message('invitation sent')
def insert(cls, form): values = form.evaluate() username = values['USERNAME'].lower() password = gen_password() values['FIRSTNAME'] = values['FIRST_NAME'] values['LASTNAME'] = values['LAST_NAME'] values['LOGINID'] = username values['PASSWORD'] = '' values['DTUPD'] = values['DTADD'] = datetime.datetime.now() values['STATUS'] = 'A' users = db.table('dz_users','USERID') id = users.insert(values) db('delete from dz_members where userid=%s', id) # make sure new users have no memberships add_user(values['LOGINID'], 'users') new_user = ZoomUser(username) new_user.set_password(password) msg = '<a href="/users/%s">%s</a> added new user <a href="/users/%s">%s</a>' logger.activity('users', msg % (user.id, user.username, new_user.id, new_user.username)) audit('created user account', new_user.username) if values['SEND_INVITATION'] == True: recipients = [values['EMAIL']] tpl = load('welcome.md') t = dict( first_name = values['FIRST_NAME'], username = username, password = password, site_name = site_name(), site_url = site_url(), admin_email = '*****@*****.**', owner_name = owner_name(), ) body = markdown(viewfill(tpl, t.get)) subject = 'Welcome - ' + site_name() send(recipients, subject, body) message('invitation sent')