diff --git a/mg/handlers/app_mg_handler.py b/mg/handlers/app_mg_handler.py index 1af8349..6c46ef5 100644 --- a/mg/handlers/app_mg_handler.py +++ b/mg/handlers/app_mg_handler.py @@ -252,7 +252,8 @@ def put(self, *args, **kwargs): token_info = dict(user_id=user_id, username=user_info.username, nickname=user_info.nickname, is_superuser=is_superuser, exp_time=1100) auth_token = AuthToken() - auth_key = auth_token.encode_auth_token(**token_info) + auth_key = auth_token.encode_auth_token_v2(**token_info) + if isinstance(auth_key, bytes): auth_key = auth_key.decode() redis_conn = cache_conn() configs_init('all') @@ -268,11 +269,11 @@ def put(self, *args, **kwargs): mail_to = session.query(Users.email).filter(Users.user_id == self.get_current_id()).first() if mail_to[0] == user_info.email: - obj.send_mail(mail_to[0], '令牌,有效期三年', auth_key.decode(), subtype='plain') + obj.send_mail(mail_to[0], '令牌,有效期三年', auth_key, subtype='plain') else: - obj.send_mail(mail_to[0], '令牌,有效期三年', auth_key.decode(), subtype='plain') - obj.send_mail(user_info.email, '令牌,有效期三年', auth_key.decode(), subtype='plain') - return self.write(dict(code=0, msg='Token已经发送到邮箱', data=auth_key.decode())) + obj.send_mail(mail_to[0], '令牌,有效期三年', auth_key, subtype='plain') + obj.send_mail(user_info.email, '令牌,有效期三年', auth_key, subtype='plain') + return self.write(dict(code=0, msg='Token已经发送到邮箱', data=auth_key)) app_mg_urls = [