fix(be/users): add quota and usedSpace to self api

This commit is contained in:
hexxa 2021-08-29 21:26:45 +08:00 committed by Hexxa
parent 8ccb194fea
commit 93d946e535
3 changed files with 15 additions and 7 deletions

View file

@ -18,7 +18,8 @@ html {
background-color: #ecf0f1;
/* background: url("bg.jpg") no-repeat left center fixed;
background-size: auto 100%; */
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
font-family: "Helvetica Neue", "Helvetica", "PingFang SC", "Microsoft YaHei",
"Arial", sans-serif;
font-size: 62.5%;
}
body {
@ -101,7 +102,7 @@ button {
border: none;
border-radius: 0.5rem;
padding: 0.8rem 1rem;
background-color: rgba(0, 0, 0, 0.3);
font-weight: bold;

View file

@ -560,10 +560,11 @@ func (h *MultiUsersSvc) isValidRole(role string) error {
}
type SelfResp struct {
ID string `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
UsedSpace int64 `json:"usedSpace,string"`
ID string `json:"id"`
Name string `json:"name"`
Role string `json:"role"`
Quota *userstore.Quota `json:"quota"`
UsedSpace int64 `json:"usedSpace,string"`
}
func (h *MultiUsersSvc) Self(c *gin.Context) {
@ -583,6 +584,7 @@ func (h *MultiUsersSvc) Self(c *gin.Context) {
ID: claims[q.UserIDParam],
Name: claims[q.UserParam],
Role: claims[q.RoleParam],
Quota: user.Quota,
UsedSpace: user.UsedSpace,
})
}

View file

@ -75,7 +75,12 @@ func TestUsersHandlers(t *testing.T) {
t.Fatal(resp.StatusCode)
} else if selfResp.ID != "0" ||
selfResp.Name != adminName ||
selfResp.Role != userstore.AdminRole {
selfResp.Role != userstore.AdminRole ||
selfResp.UsedSpace != 0 ||
selfResp.Quota.SpaceLimit != 1024*1024*1024 ||
selfResp.Quota.UploadSpeedLimit != 50*1024*1024 ||
selfResp.Quota.DownloadSpeedLimit != 50*1024*1024 {
// TODO: expose default values from userstore
t.Fatalf("user infos don't match %v", selfResp)
}