Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jms/config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
'system-user-auth-info': '/api/assets/v1/system-user/%s/auth-info/',
'validate-user-asset-permission':
'/api/perms/v1/asset-permission/user/validate/',
'is-check-otp': '/api/users/v1/is-check-otp/',
'verify-token': '/api/users/v1/verify-token/',
}
24 changes: 24 additions & 0 deletions jms/service.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,30 @@ def login(self, data):
else:
return None, None

def is_check_otp(self, remote_addr):
"""判断用户是否开启过 OTP 验证"""
data = {'remote_addr': remote_addr}
r, content = self.post('is-check-otp', data=data, use_auth=True)
if r.status_code == 200:
if content['check_otp']:
return True
else:
return False
else:
return None

def verify_token(self, otp_token, remote_addr):
"""根据用户提效的 otp_token,判断是否能够登陆"""
data = {'otp_token': otp_token, 'remote_addr': remote_addr}
r, content = self.post('verify-token', data=data, use_auth=True)
if r.status_code == 200:
if content['verify_token_result']:
return True, ''
else:
return False, content['error']
else:
return None, None

@cached(TTLCache(maxsize=100, ttl=60))
def is_authenticated(self):
"""根据签名判断用户是否认证"""
Expand Down