[Enhance] Add limiter & Building API

- Add a custom limiter and use it for limiting users' download instead of using database
> So add a requirement `limits`.

- Fix a character's value
- Change the email max length to 64
- Change something about API's roles and powers
- Add an API endpoint for getting users' roles and powers
This commit is contained in:
Lost-MSth
2022-10-12 15:27:45 +08:00
parent a04df8bba6
commit 68a83a29d2
13 changed files with 140 additions and 104 deletions

View File

@@ -63,10 +63,10 @@ def download(file_path):
x.select_for_check()
if x.is_limited:
raise ArcError(
'You have reached the download limit.', 903, status=403)
'You have reached the download limit.', 903, status=429)
if not x.is_valid:
raise ArcError('Expired token.', status=403)
x.insert_user_download()
x.download_hit()
# response = make_response()
# response.headers['Content-Type'] = 'application/octet-stream'
# response.headers['X-Accel-Redirect'] = '/nginx_download/' + file_path