From 7fb4c4d8a0a84486cf0ec4ab2fd1d09e124908cd Mon Sep 17 00:00:00 2001 From: kongkongNG <1298974109@qq.com> Date: Tue, 19 May 2020 17:11:45 +0800 Subject: [PATCH] add token into header --- backend/ddl_killer/views.py | 1 + backend/run.sh | 10 +++++----- backend/vue2-forntend/src/store/modules/user.js | 4 ++-- backend/vue2-forntend/src/utils/request.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/backend/ddl_killer/views.py b/backend/ddl_killer/views.py index 6430472..ba1bdb1 100644 --- a/backend/ddl_killer/views.py +++ b/backend/ddl_killer/views.py @@ -189,6 +189,7 @@ def login_user(request): response['name'] = '' response['code'] = 400 response['msg'] = 'The account is not active yet. Check your email to activate it.' + response['token'] = make_password(uid) return JsonResponse(response, json_dumps_params={'ensure_ascii':False}, charset='utf_8_sig') def logout_user(request): diff --git a/backend/run.sh b/backend/run.sh index ea406e7..64b7c42 100755 --- a/backend/run.sh +++ b/backend/run.sh @@ -1,12 +1,12 @@ -./halt.sh +#./halt.sh pkill -9 python -systemctl start nginx.service +#systemctl start nginx.service rm -rf vue2-forntend/dist cd vue2-forntend && cnpm run build:prod && cd .. rm -rf static -source venv/bin/activate +#source venv/bin/activate python manage.py makemigrations python manage.py collectstatic python manage.py migrate -# nohup python manage.py runserver 0.0.0.0:8000 & -uwsgi --ini uwsgi.ini +nohup python manage.py runserver 0.0.0.0:8000 & +#uwsgi --ini uwsgi.ini diff --git a/backend/vue2-forntend/src/store/modules/user.js b/backend/vue2-forntend/src/store/modules/user.js index b41d05e..ad73471 100644 --- a/backend/vue2-forntend/src/store/modules/user.js +++ b/backend/vue2-forntend/src/store/modules/user.js @@ -40,9 +40,9 @@ const actions = { // const { data } = response // console.log(response) commit('SET_NAME', response.name) - commit('SET_TOKEN', uid) + commit('SET_TOKEN', response.token) commit('SET_ID', uid) - setToken(uid) + setToken(response.token) setUid(uid) setName(response.name) resolve(response) diff --git a/backend/vue2-forntend/src/utils/request.js b/backend/vue2-forntend/src/utils/request.js index 618a920..c846529 100644 --- a/backend/vue2-forntend/src/utils/request.js +++ b/backend/vue2-forntend/src/utils/request.js @@ -19,7 +19,7 @@ service.interceptors.request.use( // let each request carry token // ['X-Token'] is a custom headers key // please modify it according to the actual situation - config.headers['X-Token'] = getToken() + config.headers.Authorization = getToken() } return config }, -- Gitee