return templates['addhost.html'](suffixes=suffixes, current_ip=bottle.request.remote_addr) @route('/user/hosts/add', method='POST') @authorized() @validate('/user/hosts/add', hostname=validation.ValidHostname(), suffix=validation.Int(not_empty=True), address=validation.IPAddress(), address_v6=validation.IPv6Address(), description=validation.String(max=255), password=validation.SecurePassword(min=8), password_confirm=validation.String(), chained_validators=[ validation.FieldsMatch('password', 'password_confirm'), validation.UniqueHostname('hostname', 'suffix') ]) @require(db='dynserver.db:Database', config='dynserver.config:Config', messages='dynserver.interface.message:MessageManager') def post_hosts_add(user, data, db, config, messages): ''' Add a new hostname. ''' # We do net check passed suffix, as mysql will tell us later on with db.cursor() as cur: # Users can have an individual hostname limit, unlimited hostnames (-1) # or have no limit set in the db to use the default from the config cur.execute( '''
WHERE `id` = %(id)s ''', {'email': data.email, 'id': user.id}) messages.success('Ok, done.') bottle.redirect('/user/account') @route('/user/account/password', method = 'POST') @authorized() @validate('/user/account', password = validation.SecurePassword(min = 8), password_confirm = validation.String(), chained_validators = [validation.FieldsMatch('password', 'password_confirm')]) @require(db = 'dynserver.db:Database', messages = 'dynserver.interface.message:MessageManager') def post_account_password(user, data, db, messages): ''' Update the users password. ''' encrypted_password = pwd.encrypt(data.password) with db.cursor() as cur: cur.execute(''' UPDATE `users` SET `password` = %(newpass)s WHERE `id` = %(id)s