Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

Commit 239ec35

Browse files
authored
Merge pull request #79 from ProgrammingLab/response_admin
Authority in response
2 parents 228077d + e8e00d6 commit 239ec35

12 files changed

+212
-84
lines changed

api/achievements.swagger.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@
229229
}
230230
}
231231
},
232+
"prolab_accountsAuthority": {
233+
"type": "string",
234+
"enum": [
235+
"MEMBER",
236+
"ADMIN"
237+
],
238+
"default": "MEMBER"
239+
},
232240
"prolab_accountsDepartment": {
233241
"type": "object",
234242
"properties": {
@@ -341,6 +349,9 @@
341349
},
342350
"display_name": {
343351
"type": "string"
352+
},
353+
"authority": {
354+
"$ref": "#/definitions/prolab_accountsAuthority"
344355
}
345356
}
346357
},

api/achievements.validator.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/contribution_conllections.swagger.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
}
4343
},
4444
"definitions": {
45+
"prolab_accountsAuthority": {
46+
"type": "string",
47+
"enum": [
48+
"MEMBER",
49+
"ADMIN"
50+
],
51+
"default": "MEMBER"
52+
},
4553
"prolab_accountsContributionConllection": {
4654
"type": "object",
4755
"properties": {
@@ -169,6 +177,9 @@
169177
},
170178
"display_name": {
171179
"type": "string"
180+
},
181+
"authority": {
182+
"$ref": "#/definitions/prolab_accountsAuthority"
172183
}
173184
}
174185
}

api/email_confirmations.validator.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/entries.swagger.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
}
5050
},
5151
"definitions": {
52+
"prolab_accountsAuthority": {
53+
"type": "string",
54+
"enum": [
55+
"MEMBER",
56+
"ADMIN"
57+
],
58+
"default": "MEMBER"
59+
},
5260
"prolab_accountsBlog": {
5361
"type": "object",
5462
"properties": {
@@ -202,6 +210,9 @@
202210
},
203211
"display_name": {
204212
"type": "string"
213+
},
214+
"authority": {
215+
"$ref": "#/definitions/prolab_accountsAuthority"
205216
}
206217
}
207218
}

api/entries.validator.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/oauth.validator.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/password_resets.validator.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protos/users.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ message User {
7575
ProfileScope profile_scope = 15;
7676
string atcoder_user_name = 16;
7777
string display_name = 17;
78+
Authority authority = 18;
7879
}
7980

8081
enum ProfileScope {
8182
MEMBERS_ONLY = 0;
8283
PUBLIC = 1;
8384
}
8485

86+
enum Authority {
87+
MEMBER = 0;
88+
ADMIN = 1;
89+
}
90+
8591
message ListUsersRequest {
8692
uint32 page_token = 1;
8793
int32 page_size = 2;

api/users.pb.go

Lines changed: 143 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/users.swagger.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@
243243
}
244244
},
245245
"definitions": {
246+
"prolab_accountsAuthority": {
247+
"type": "string",
248+
"enum": [
249+
"MEMBER",
250+
"ADMIN"
251+
],
252+
"default": "MEMBER"
253+
},
246254
"prolab_accountsCreateUserRequest": {
247255
"type": "object",
248256
"properties": {
@@ -423,6 +431,9 @@
423431
},
424432
"display_name": {
425433
"type": "string"
434+
},
435+
"authority": {
436+
"$ref": "#/definitions/prolab_accountsAuthority"
426437
}
427438
}
428439
}

app/server/users_server.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ func userToResponse(user *record.User, includePrivate bool, cfg *config.Config)
338338
}
339339

340340
u := &api_pb.User{
341-
UserId: uint32(user.ID),
342-
Name: user.Name,
341+
UserId: uint32(user.ID),
342+
Name: user.Name,
343+
Authority: authorityToResponse(model.Authority(user.Authority)),
343344
}
344345
if includePrivate {
345346
u.Email = user.Email
@@ -372,6 +373,17 @@ func userToResponse(user *record.User, includePrivate bool, cfg *config.Config)
372373
return u
373374
}
374375

376+
func authorityToResponse(a model.Authority) api_pb.Authority {
377+
switch a {
378+
case model.Member:
379+
return api_pb.Authority_MEMBER
380+
case model.Admin:
381+
return api_pb.Authority_ADMIN
382+
default:
383+
return api_pb.Authority_MEMBER
384+
}
385+
}
386+
375387
func profileScopeToResponse(scope model.ProfileScope) api_pb.ProfileScope {
376388
switch scope {
377389
case model.MembersOnly:

0 commit comments

Comments
 (0)