2020-09-16 21:41:55 +00:00
|
|
|
from log import logger
|
|
|
|
import time
|
|
|
|
import secrets
|
2020-09-16 22:14:27 +00:00
|
|
|
import subprocess
|
2020-09-16 21:41:55 +00:00
|
|
|
|
|
|
|
from flask import abort
|
|
|
|
|
|
|
|
HTTP_NOTFOUND = 404
|
|
|
|
|
2020-09-16 22:14:27 +00:00
|
|
|
def set_wiki_password(username, password):
|
|
|
|
# sets a user's wiki password
|
|
|
|
# creates the account if it doesn't exist
|
|
|
|
|
|
|
|
if not username:
|
|
|
|
logger.error('Empty username, aborting')
|
|
|
|
abort(400)
|
|
|
|
|
|
|
|
logger.info('Setting wiki password for: ' + username)
|
|
|
|
|
|
|
|
if not password:
|
|
|
|
logger.error('Empty password, aborting')
|
|
|
|
abort(400)
|
|
|
|
|
|
|
|
script = secrets.WIKI_MAINTENANCE + '/createAndPromote.php'
|
|
|
|
|
|
|
|
result = subprocess.run(['php', script, '--force', username, password],
|
|
|
|
shell=False, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
output = result.stdout or result.stderr
|
|
|
|
|
|
|
|
logger.info('Output: ' + output)
|
|
|
|
|
|
|
|
if result.stderr:
|
|
|
|
abort(400)
|
2020-09-16 21:41:55 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-09-16 22:14:27 +00:00
|
|
|
set_wiki_password('tanner.collin', 'protospace1')
|
2020-09-16 21:41:55 +00:00
|
|
|
pass
|