Fix logging in in prebuilds

This commit is contained in:
wvffle 2022-07-02 00:41:38 +00:00
parent abd60caa09
commit fae6bc9184
2 changed files with 5 additions and 8 deletions

View File

@ -34,7 +34,7 @@ tasks:
# Login with cURL to create actors
docker-compose up -d nginx
gp ports await 8000
sleep 20 # allow django to start
sleep 10
python .gitpod/init_actor.py
# Import music

View File

@ -1,20 +1,17 @@
import subprocess
import requests
INSTANCE_URL = subprocess.check_output(['gp', 'url', '8000']).decode()[:-1]
# Login to initialize user actor
req = requests.Session()
res = req.get(INSTANCE_URL + '/login')
res = req.get('http://localhost:8000/login')
token = res.cookies['csrftoken']
req.post(INSTANCE_URL + '/api/v1/users/login', data={
req.post('http://localhost:8000/api/v1/users/login', data={
'username': 'gitpod',
'password': 'gitpod'
}, headers={
'Referer': INSTANCE_URL + '/login',
'Referer': 'http://localhost:8000/login',
'X-CSRFTOKEN': token
})
req.get(INSTANCE_URL)
req.get('http://localhost:8000')