Skip to content

Commit

Permalink
2024年6月07日 feat(login) 优化登录根域写cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
ss1917 committed Jun 13, 2024
1 parent f0b555c commit e6816ba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mg/handlers/login_v5_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,19 @@ async def post(self, *args, **kwargs):

if c_url:
# 暂用逻辑
# try:
# c_domain = get_domain_from_url(c_url)
# self.set_cookie("auth_key", auth_key, domain=c_domain, expires_days=1)
# self.set_cookie("is_login", 'yes', domain=c_domain, expires_days=1)
# except Exception as err:
# logging.error(f"设置主域cookie失败 {err}")
try:
c_domain = get_domain_from_url(c_url)
self.set_cookie("auth_key", auth_key, domain=c_domain, expires_days=1)
self.set_cookie("is_login", 'yes', domain=c_domain, expires_days=1)
root_domain = self.request.headers.get('Codo-root-domain')
self.clear_all_cookies()
self.set_cookie("auth_key", auth_key, domain=root_domain, expires_days=1)
self.set_cookie("is_login", 'yes', domain=root_domain, expires_days=1)
except Exception as err:
logging.error(f"设置主域cookie失败 {err}")
pass

real_login_dict = dict(code=0, username=user_info.username, nickname=user_info.nickname, auth_key=auth_key,
avatar=user_info.avatar, c_url=c_url, msg='登录成功')
Expand Down

0 comments on commit e6816ba

Please sign in to comment.