def general(): provider = Provider() filesystem = provider.filesystem() themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) return render_template('config/system/general.html', themes=themes)
def settings_general_save(): provider = Provider() settings = provider.settings() filesystem = provider.filesystem() if not current_user.admin: flash('Access Denied', 'error') return redirect(url_for('home.index')) wordlists_path = request.form['wordlists_path'].strip() uploaded_hashes_path = request.form['uploaded_hashes_path'].strip() theme = request.form['theme'].strip() webpush_enabled = int(request.form.get('webpush_enabled', 0)) vapid_private = request.form['vapid_private'].strip() vapid_public = request.form['vapid_public'].strip() has_errors = False if len(wordlists_path) == 0 or not os.path.isdir(wordlists_path): has_errors = True flash('Wordlist directory does not exist', 'error') elif not os.access(wordlists_path, os.R_OK): has_errors = True flash('Wordlist directory is not readable', 'error') if len(uploaded_hashes_path) > 0 and not os.path.isdir( uploaded_hashes_path): has_errors = True flash('Uploaded Hashes directory does not exist', 'error') elif len(uploaded_hashes_path) > 0 and not os.access( uploaded_hashes_path, os.R_OK): has_errors = True flash('Uploaded Hashes directory is not readable', 'error') themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) if not (theme + '.css') in themes: flash('Invalid theme', 'error') return redirect(url_for('admin.settings_general')) if has_errors: return redirect(url_for('admin.settings_general')) settings.save('wordlists_path', wordlists_path) settings.save('uploaded_hashes_path', uploaded_hashes_path) settings.save('theme', theme) # Only update if it's not '********' because we don't show it in the UI. if vapid_private != '********': settings.save('vapid_private', vapid_private) settings.save('vapid_public', vapid_public) settings.save('webpush_enabled', webpush_enabled) flash('Settings saved', 'success') return redirect(url_for('admin.settings_general'))
def settings_general(): if not current_user.admin: flash('Access Denied', 'error') return redirect(url_for('home.index')) provider = Provider() filesystem = provider.filesystem() themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) return render_template('admin/settings/general.html', themes=themes)
def general_save(): provider = Provider() settings = provider.settings() filesystem = provider.filesystem() theme = request.form['theme'].strip() themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) if not (theme + '.css') in themes: flash('Invalid theme', 'error') return redirect(url_for('config.general')) settings.save('theme', theme) flash('Settings saved', 'success') return redirect(url_for('config.general'))
def theme(): provider = Provider() users = provider.users() filesystem = provider.filesystem() user_settings = provider.user_settings() settings = provider.settings() user = users.get_by_id(current_user.id) themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) theme = user_settings.get(current_user.id, 'theme', settings.get('theme', 'lumen')) return render_template('config/account/theme.html', user=user, themes=themes, selected_theme=theme)
def theme_save(): theme = request.form['theme'].strip() provider = Provider() filesystem = provider.filesystem() user_settings = provider.user_settings() themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) if not (theme + '.css') in themes: flash('Invalid theme', 'error') return redirect(url_for('config.theme', user_id=current_user.id)) user_settings.save(current_user.id, 'theme', theme) flash( 'Theme saved. To make sure everything is working, please force-refresh the page (CTRL-F5)', 'success') return redirect(url_for('config.theme', user_id=current_user.id))
def theme(user_id): if current_user.id != user_id: flash('Access denied', 'error') return redirect(url_for('home.index')) provider = Provider() users = provider.users() filesystem = provider.filesystem() user_settings = provider.user_settings() settings = provider.settings() user = users.get_by_id(current_user.id) themes = filesystem.get_files( os.path.join(current_app.root_path, 'static', 'css', 'themes')) theme = user_settings.get(user_id, 'theme', settings.get('theme', 'lumen')) return render_template('account/theme.html', user=user, themes=themes, selected_theme=theme)