def post(self): if 'logout' in flask.request.form: flask.session.pop('username', None) flask.session.pop('admin', None) return flask.redirect(flask.url_for('main')) required = ['username', 'password'] app.logger.debug("required = " + required[0] + " & " + required[1]) for r in required: if r not in flask.request.form or flask.request.form[r] == "": flask.flash("Error: {0} is required.".format(r)) return flask.redirect(flask.url_for('login')) username = flask.request.form['username'] password = flask.request.form['password'] app.logger.debug("username = "******"password = "******"users[username]['password'] = "******"admin status = " + users[username]['admin']) if users[username]['admin'] == 'True': app.logger.debug("users[username]['admin'] = " + users[username]['admin']) flask.session['admin'] = 'True' else: app.logger.debug("password after = " + password) flask.flash("Username doesn't exist or incorrect password") return flask.redirect(flask.url_for('login')) return flask.redirect(flask.url_for('new_ftp_user'))
def post(self): # Maybe use this later? # form = NewFtpForm() # Check to see if we're valid #f not flask.request.form.validate_on_submit(): # flask.flash("Invalid username") # return self.get # Load in users from chef and check to see if we're putting in a duplicate admin_users = utils.load_admins() new_admin = flask.request.form['admin_username'] app.logger.debug("Checking. . .") app.logger.debug("is_admin = " + str(flask.request.form.getlist('is_admin'))) if str(flask.request.form.getlist('is_admin')) == 'on': admin_status = 'True' else: admin_status = 'False' app.logger.debug("What about here?") app.logger.debug("new_admin = " + new_admin) if utils.user_exists(new_admin, admin_users): flash('Admin account for ' + new_admin + ' already exists!') return self.get() # Generate password (see below) and return back to ftp, displaying new pwd pwd = utils.new_random_password() app.logger.debug(new_admin + "=" + pwd) admin_users[new_admin] = {"admin": admin_status, "password": pwd} utils.persist_admins(new_admin, admin_users) flash('Admin account for ' + new_admin + ' created! Password is ' + pwd) return self.get()
def post(self): users_to_del = flask.request.form.getlist('del_list') app.logger.debug("users to del = " + str(users_to_del) ) all_users = utils.load_admins() app.logger.debug("all_users size = " + str(len(all_users)) ) for u in users_to_del: all_users.pop(u) app.logger.debug("all_users size = " + str(len(all_users)) ) utils.persist_admins(users_to_del, all_users) flask.flash("Admin Accounts have been deleted: " + json.dumps(users_to_del) ) return redirect('/admin/list')
driver.delete_all_cookies() try: result, string_output = test_function(ip, group_id, driver) except Exception as exception: logger.log_warn( 'test for for team "{}" with group_id {} ended with exception'. format(team_names[int(group_id)], group_id)) return False, ('Exception: ' + str(exception)), 'HMM' return result, string_output, 'HMM' def runserver(port=config.PORT): app.run(host=config.HOST, port=port) if __name__ == '__main__': try: utils.load_admins("admins.json") if len(sys.argv) > 1: server_port = int(sys.argv[1]) logger.log_info('starting server on custom port', server_port) runserver(server_port) else: logger.log_info('starting server on default port') runserver() except Exception: for gid in group_status: group_status[gid]['driver'].close()
def get(self): admin_users = utils.load_admins() app.logger.debug("In get, admin_user = " + str(admin_users)) return render_template('admin_users.html', title='Admin Users', admin_users=admin_users)
def get(self): admin_users = utils.load_admins() return render_template('del_admin_users.html', title='Delete Admin Users', admin_users=admin_users)