1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-vps-admin.git synced 2025-02-12 10:31:52 +00:00

Add SOF-67: Returning total number of users by Dillon Ward

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-05-28 14:51:51 +02:00
parent b0d2f8126c
commit f9d5fc750c
2 changed files with 15 additions and 0 deletions

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
omr-vps-admin (0.9+20240528) unstable; urgency=medium
* Add SOF-67: Returning total number of users by Dillon Ward
-- OpenMPTCProuter <contact@openmptcprouter.com> Tue, 28 May 2024 14:50:19 +0200
omr-vps-admin (0.9+20240516) unstable; urgency=medium
* Fix Shadowsocks-Go user creation

View file

@ -3284,6 +3284,15 @@ async def list_users(current_user: User = Depends(get_current_user)):
content = json.load(f)
return content['users'][0]
@app.get('/get-number-of-users', summary="Get the total number of users")
def get_number_of_users(current_user: User = Depends(get_current_user)):
if not current_user.permissions == "admin":
return {'result': 'permission', 'reason': 'Need admin user', 'route': 'get-number-of-users'}
with open('/etc/openmptcprouter-vps-admin/omr-admin-config.json') as f:
content = json.load(f)
users = len(content['users'][0]) - 1
return {'users': users}
@app.get('/speedtest', summary="Test speed from the server")
async def speedtest(current_user: User = Depends(get_current_user)):
return FileResponse('/usr/share/omr-server/speedtest/test.img')