add webinterface token

#154
This commit is contained in:
Azlux
2020-05-17 20:28:27 +02:00
parent 1d97fe654e
commit 4017e7bff0
5 changed files with 73 additions and 9 deletions

View File

@ -65,7 +65,7 @@ def register_all_commands(bot):
bot.register_command(constants.commands('delete_from_library'), cmd_delete_from_library)
bot.register_command(constants.commands('drop_database'), cmd_drop_database, no_partial_match=True)
bot.register_command(constants.commands('rescan'), cmd_refresh_cache, no_partial_match=True)
bot.register_command(constants.commands('requests_webinterface_access'), cmd_web_access)
# Just for debug use
bot.register_command('rtrms', cmd_real_time_rms, True)
#bot.register_command('loop', cmd_loop_state, True)
@ -1179,6 +1179,14 @@ def cmd_refresh_cache(bot, user, text, command, parameter):
bot.mumble.users[text.actor].send_text_message(constants.strings('not_admin'))
def cmd_web_access(bot, user, text, command, parameter):
import secrets
import datetime
import json
token = secrets.token_urlsafe(5)
var.db.set("user", user, json.dumps({'token': token, 'datetime': str(datetime.datetime.now()), 'IP':''}))
bot.send_msg(constants.strings('webpage_token',token=token), text)
# Just for debug use
def cmd_real_time_rms(bot, user, text, command, parameter):
bot._display_rms = not bot._display_rms