Skip to content

Commit

Permalink
处理protocol与host信息
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryJi529 committed Jun 5, 2024
1 parent b11c2fc commit 218c90b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 1 addition & 7 deletions Morningstar/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ def create_activate_message(username, host):
except:
pass
conn.set(f"{username}-activate", code, ex=60 * 10)

protocol = (
"https://"
if os.environ.get("DJANGO_SETTINGS_MODULE", "Morningstar.settings.dev")
== "Morningstar.settings.production"
else "http://"
)
protocol = "https://" if request.is_secure() else "http://"
link = (
protocol
+ host
Expand Down
7 changes: 1 addition & 6 deletions Morningstar/views/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,7 @@ def get_login_token(request: HttpRequest, identity):
username = user.username
password = user.password
token = html.escape(password[-20:])
protocol = (
"https://"
if os.environ.get("DJANGO_SETTINGS_MODULE", "Morningstar.settings.dev")
== "Morningstar.settings.production"
else "http://"
)
protocol = "https://" if request.is_secure() else "http://"
link = (
protocol
+ request.get_host()
Expand Down
5 changes: 4 additions & 1 deletion apps/share/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ def submit(request: HttpRequest):
item.save()
id = item.id
link = f"redirect/{id}/"
request.session["share-qrcode"] = "https://morningstar369.com/share/" + link
protocol = "https://" if request.is_secure() else "http://"
request.session["share-qrcode"] = (
protocol + request.META["HTTP_HOST"] + "/share/" + link
)
return Response({"link": link})

0 comments on commit 218c90b

Please sign in to comment.