Fix docker-run and login endpoint
This commit is contained in:
parent
e9d48e863c
commit
e48cd26cb0
@ -5,19 +5,20 @@ cd /opt/maubot
|
|||||||
# Replace database path in config.
|
# Replace database path in config.
|
||||||
sed -i "s#sqlite:///maubot.db#sqlite:////data/maubot.db#" /data/config.yaml
|
sed -i "s#sqlite:///maubot.db#sqlite:////data/maubot.db#" /data/config.yaml
|
||||||
sed -i "s#- ./plugins#- /data/plugins#" /data/config.yaml
|
sed -i "s#- ./plugins#- /data/plugins#" /data/config.yaml
|
||||||
|
sed -i "s#upload: ./plugins#upload: /data/plugins#" /data/config.yaml
|
||||||
|
sed -i "s#trash: ./trash#trash: /data/trash#" /data/config.yaml
|
||||||
|
sed -i "s#db: ./plugins#trash: /data/dbs#" /data/config.yaml
|
||||||
sed -i "s#./logs/maubot.log#/var/log/maubot/maubot.log#" /data/config.yaml
|
sed -i "s#./logs/maubot.log#/var/log/maubot/maubot.log#" /data/config.yaml
|
||||||
|
|
||||||
mkdir -p /var/log/maubot
|
mkdir -p /var/log/maubot /data/plugins /data/trash /data/dbs
|
||||||
|
|
||||||
# Check that database is in the right state
|
# Check that database is in the right state
|
||||||
alembic -x config=/data/config.yaml upgrade head
|
alembic -x config=/data/config.yaml upgrade head
|
||||||
|
|
||||||
if [ ! -f /data/config.yaml ]; then
|
if [ ! -f /data/config.yaml ]; then
|
||||||
cp example-config.yaml /data/config.yaml
|
cp example-config.yaml /data/config.yaml
|
||||||
echo "Didn't find a config file."
|
echo "Config file not found. Example config copied to /data/config.yaml"
|
||||||
echo "Copied default config file to /data/config.yaml"
|
echo "Please modify the config file to your liking and restart the container."
|
||||||
echo "Modify that config file to your liking."
|
|
||||||
echo "Start the container again after that to generate the registration file."
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ async def login(request: web.Request) -> web.Response:
|
|||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return ErrBodyNotJSON
|
return ErrBodyNotJSON
|
||||||
secret = data.get("secret")
|
secret = data.get("secret")
|
||||||
if secret and config["server.unshared_secret"] == secret:
|
if secret and get_config()["server.unshared_secret"] == secret:
|
||||||
user = data.get("user") or "root"
|
user = data.get("user") or "root"
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
"token": create_token(user),
|
"token": create_token(user),
|
||||||
@ -51,7 +51,7 @@ async def login(request: web.Request) -> web.Response:
|
|||||||
|
|
||||||
username = data.get("username")
|
username = data.get("username")
|
||||||
password = data.get("password")
|
password = data.get("password")
|
||||||
if config.check_password(username, password):
|
if get_config().check_password(username, password):
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
"token": create_token(username),
|
"token": create_token(username),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user