-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support basic account action for admin #934
Support basic account action for admin #934
Conversation
Warning Rate limit exceeded@gusah009 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 52 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis update enhances the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
6d60b0a
to
98dc7c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
Files selected for processing (10)
- api/docs/yorkie/v1/admin.openapi.yaml (8 hunks)
- api/types/user_fields.go (2 hunks)
- api/yorkie/v1/admin.proto (2 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- server/backend/database/database.go (1 hunks)
- server/backend/database/memory/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
- server/rpc/admin_server.go (1 hunks)
- server/rpc/interceptors/admin.go (1 hunks)
- server/users/users.go (1 hunks)
Additional comments not posted (34)
api/types/user_fields.go (3)
25-25
: LGTM!The comment update provides clarity on the relationship between
SignupFields
andChangePasswordFields
.
39-47
: LGTM!The
ChangePasswordFields
struct is well-defined and consistent withSignupFields
. The validation rules are appropriate.
49-52
: LGTM!The
Validate
method forChangePasswordFields
is consistent with the existingSignupFields
validation.server/users/users.go (1)
98-109
: LGTM!The
DeleteAccountByName
function is straightforward and handles errors appropriately.api/yorkie/v1/admin.proto (6)
31-31
: LGTM!The
DeleteAccount
RPC is well-defined and follows the existing pattern.
32-32
: LGTM!The
ChangePassword
RPC is well-defined and follows the existing pattern.
67-70
: LGTM!The
DeleteAccountRequest
message is well-defined and includes necessary fields for account deletion.
72-73
: LGTM!The
DeleteAccountResponse
message is appropriately defined as an acknowledgment.
75-79
: LGTM!The
ChangePasswordRequest
message is well-defined and includes necessary fields for password change.
81-82
: LGTM!The
ChangePasswordResponse
message is appropriately defined as an acknowledgment.server/rpc/interceptors/admin.go (1)
45-47
: Verify the security implications of excludingChangePassword
andDeleteAccount
from authentication.Excluding these methods from authentication checks might expose security vulnerabilities. Ensure that these methods should indeed be accessible without authentication.
server/backend/database/database.go (2)
146-147
: LGTM! Verify error handling forDeleteUserInfoByName
.The method enhances the interface's functionality for user management. Ensure that potential errors and edge cases are handled correctly.
149-150
: LGTM! Verify error handling forChangePassword
.The method enhances the interface's functionality for user management. Ensure that potential errors and edge cases are handled correctly.
server/rpc/admin_server.go (2)
98-119
: LGTM! Verify error handling forDeleteAccount
.The method enhances the server's capabilities for user account management. Ensure that potential errors and edge cases are handled correctly.
121-147
: LGTM! Verify error handling forChangePassword
.The method enhances the server's capabilities for user account management. Ensure that potential errors and edge cases are handled correctly.
api/yorkie/v1/v1connect/admin.connect.go (13)
55-57
: LGTM!The addition of
AdminServiceDeleteAccountProcedure
is correct and aligns with the new RPC procedure.
58-60
: LGTM!The addition of
AdminServiceChangePasswordProcedure
is correct and aligns with the new RPC procedure.
99-99
: LGTM!The addition of the
DeleteAccount
method in theAdminServiceClient
interface is correct and aligns with the new RPC procedure.
100-100
: LGTM!The addition of the
ChangePassword
method in theAdminServiceClient
interface is correct and aligns with the new RPC procedure.
206-206
: LGTM!The addition of the
deleteAccount
client in theadminServiceClient
struct is correct and aligns with the new RPC procedure.
207-207
: LGTM!The addition of the
changePassword
client in theadminServiceClient
struct is correct and aligns with the new RPC procedure.
231-234
: LGTM!The addition of the
DeleteAccount
method in theadminServiceClient
implementation is correct and aligns with the new RPC procedure.
236-239
: LGTM!The addition of the
ChangePassword
method in theadminServiceClient
implementation is correct and aligns with the new RPC procedure.
300-300
: LGTM!The addition of the
DeleteAccount
method in theAdminServiceHandler
interface is correct and aligns with the new RPC procedure.
301-301
: LGTM!The addition of the
ChangePassword
method in theAdminServiceHandler
interface is correct and aligns with the new RPC procedure.
331-335
: LGTM!The addition of the
adminServiceDeleteAccountHandler
in theNewAdminServiceHandler
function is correct and aligns with the new RPC procedure.
336-340
: LGTM!The addition of the
adminServiceChangePasswordHandler
in theNewAdminServiceHandler
function is correct and aligns with the new RPC procedure.
445-451
: LGTM!The addition of the unimplemented
DeleteAccount
andChangePassword
methods in theUnimplementedAdminServiceHandler
is correct and aligns with the new RPC procedures.api/docs/yorkie/v1/admin.openapi.yaml (6)
18-20
: Ensure response schema exists.The response references
yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordResponse
. Verify that this schema is defined correctly undercomponents/responses
.Verification successful
Ensure response schema exists.
The
yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordResponse
schema is correctly referenced and defined undercomponents/schemas
asyorkie.v1.ChangePasswordResponse
.
api/docs/yorkie/v1/admin.openapi.yaml
: Lines defining the schema reference and its title.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the ChangePasswordResponse schema. # Test: Search for the ChangePasswordResponse schema. Expect: Schema definition exists. rg --type yaml $'ChangePasswordResponse'Length of output: 677
42-44
: Ensure response schema exists.The response references
yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse
. Verify that this schema is defined correctly undercomponents/responses
.Verification successful
The
DeleteAccountResponse
schema is defined and correctly referenced.The schema
DeleteAccountResponse
exists undercomponents/schemas
and is correctly referenced in theapi/docs/yorkie/v1/admin.openapi.yaml
file.
- Lines confirming the existence and definition:
api/docs/yorkie/v1/admin.openapi.yaml: yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse:
api/docs/yorkie/v1/admin.openapi.yaml: $ref: '#/components/schemas/yorkie.v1.DeleteAccountResponse'
api/docs/yorkie/v1.admin.openapi.yaml: yorkie.v1.DeleteAccountResponse:
api/docs/yorkie/v1/admin.openapi.yaml: title: DeleteAccountResponse
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the DeleteAccountResponse schema. # Test: Search for the DeleteAccountResponse schema. Expect: Schema definition exists. rg --type yaml $'DeleteAccountResponse'Length of output: 668
674-693
: Ensure property data types are correct.The properties
currentPassword
,newPassword
, andusername
are defined as strings. Verify that these properties align with the expected data types.Verification successful
Ensure property data types are correct.
The properties
currentPassword
,newPassword
, andusername
in theyorkie.v1.ChangePasswordRequest
schema are correctly defined as strings.
currentPassword
: type: stringnewPassword
: type: stringusername
: type: stringScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the data types of properties in ChangePasswordRequest schema. # Test: Search for the property definitions. Expect: Properties are defined as strings. rg --type yaml -A 5 $'ChangePasswordRequest'Length of output: 2395
Script:
#!/bin/bash # Description: Verify the complete property definitions in ChangePasswordRequest schema. # Test: Search for the complete property definitions. Expect: Properties are defined as strings. rg --type yaml -A 10 $'yorkie.v1.ChangePasswordRequest'Length of output: 3029
Script:
#!/bin/bash # Description: Verify the complete property definitions in ChangePasswordRequest schema. # Test: Search for the complete property definitions. Expect: Properties are defined as strings. rg --type yaml -A 20 $'yorkie.v1.ChangePasswordRequest'Length of output: 5272
13-17
: Ensure request body schema exists.The request body references
yorkie.v1.AdminService.ChangePassword.yorkie.v1.ChangePasswordRequest
. Verify that this schema is defined correctly undercomponents/requestBodies
.
723-737
: Ensure property data types are correct.The properties
password
andusername
are defined as strings. Verify that these properties align with the expected data types.Verification successful
Ensure property data types are correct.
The properties
password
andusername
in theDeleteAccountRequest
schema are both correctly defined as strings.
password
: type: stringusername
: type: stringScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the data types of properties in DeleteAccountRequest schema. # Test: Search for the property definitions. Expect: Properties are defined as strings. rg --type yaml -A 5 $'DeleteAccountRequest'Length of output: 2371
Script:
#!/bin/bash # Description: Verify the data types of properties in DeleteAccountRequest schema. # Test: Search for the specific data type definitions of the `password` and `username` properties. rg --type yaml -A 3 -B 2 $'password:\n type: string' api/docs/yorkie/v1/admin.openapi.yaml rg --type yaml -A 3 -B 2 $'username:\n type: string' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 567
Script:
#!/bin/bash # Description: Verify the data types of properties in DeleteAccountRequest schema. # Test: Search for the specific data type definitions of the `password` and `username` properties using multiline mode. rg --multiline --type yaml -A 3 -B 2 $'password:\n type: string' api/docs/yorkie/v1/admin.openapi.yaml rg --multiline --type yaml -A 3 -B 2 $'username:\n type: string' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 207
Script:
#!/bin/bash # Description: Verify the data types of properties in DeleteAccountRequest schema. # Test: Search for the entire schema definition of `DeleteAccountRequest` and include surrounding lines for context. rg --multiline --type yaml -A 10 -B 2 'yorkie.v1.DeleteAccountRequest' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 1714
Script:
#!/bin/bash # Description: Verify the data types of properties in DeleteAccountRequest schema. # Test: Search for the entire schema definition of `DeleteAccountRequest` and include more surrounding lines for context. rg --multiline --type yaml -A 15 -B 2 'yorkie.v1.DeleteAccountRequest' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 2307
37-41
: Ensure request body schema exists.The request body references
yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest
. Verify that this schema is defined correctly undercomponents/requestBodies
.Verification successful
The
yorkie.v1.DeleteAccountRequest
schema is defined in theadmin.openapi.yaml
file.
- The schema
yorkie.v1.DeleteAccountRequest
is present undercomponents/schemas
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the DeleteAccountRequest schema. # Test: Search for the DeleteAccountRequest schema. Expect: Schema definition exists. rg --type yaml $'DeleteAccountRequest'Length of output: 663
Script:
#!/bin/bash # Description: Verify the existence of the yorkie.v1.DeleteAccountRequest schema. # Test: Search for the yorkie.v1.DeleteAccountRequest schema. Expect: Schema definition exists. rg --type yaml $'components:\n schemas:\n yorkie.v1.DeleteAccountRequest'Length of output: 268
Script:
#!/bin/bash # Description: Verify the existence of the yorkie.v1.DeleteAccountRequest schema. # Test: Search for the yorkie.v1.DeleteAccountRequest schema. Expect: Schema definition exists. rg --type yaml --multiline $'components:\n schemas:\n yorkie.v1.DeleteAccountRequest'Length of output: 88
Script:
#!/bin/bash # Description: Search for any occurrence of the yorkie.v1.DeleteAccountRequest schema. # Test: Search for the yorkie.v1.DeleteAccountRequest schema. Expect: Schema definition or reference exists. rg --type yaml 'yorkie.v1.DeleteAccountRequest'Length of output: 601
Script:
#!/bin/bash # Description: Search for the definition of the yorkie.v1.DeleteAccountRequest schema. # Test: Search for the definition of yorkie.v1.DeleteAccountRequest. Expect: Schema definition exists. rg --type yaml --multiline 'yorkie.v1.DeleteAccountRequest:\n'Length of output: 249
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
I have two things to suggest:
-
User vs. Account
As you can see in the database, we are using the wordUser
, so we might need to keep consistency for the word describing "user". -
Test codes for Admin RPC
How about adding test codes for newly introduced APIs?TestAdminRPCServerBackend()
test function inserver/rpc/server_test.go
will be the best place to put test codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (3)
api/types/user_fields_test.go (1)
34-34
: Update function name for consistency.Ensure that the function name
TestSignupFields
is updated toTestUserFields
to reflect the new struct name.
api/types/user_fields_test.go: func TestSignupFields(t *testing.T)
Analysis chain
LGTM! But verify the struct usage in the codebase.
The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.
Verify the struct renaming consistency.
The renaming of the struct to
UserFields
appears consistent across the codebase. To ensure completeness, verify that there are no remaining instances of the old struct nameSignupFields
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
Script:
#!/bin/bash # Description: Verify there are no remaining instances of the old struct name `SignupFields`. # Test: Search for any lingering instances of `SignupFields`. Expect: No occurrences. rg --type go -A 5 $'SignupFields'Length of output: 404
admin/client.go (1)
159-165
: Ensure all instances of theSignUp
method are updated toCreateUser
.The transition from
SignUp
toCreateUser
is in progress, but there are still references to the deprecatedSignUp
method. Verify that all calls to the old method have been updated to use the newCreateUser
method.
server/rpc/admin_server.go
: DeprecatedSignUp
method still present.server/rpc/testcases/testcases.go
: Test cases still usingSignUp
.api/yorkie/v1/v1connect/admin.connect.go
: DeprecatedSignUp
method still present.Analysis chain
LGTM! Ensure the new method is used correctly throughout the codebase.
The
CreateUser
method replaces the previousSignUp
method, improving clarity. Verify that all calls to the old method have been updated.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `CreateUser` match the new method signature. # Test: Search for the function usage. Expect: Only occurrences of the new method name. rg --type go -A 5 $'CreateUser'Length of output: 23349
server/rpc/testcases/testcases.go (1)
641-641
: Update function documentation to reflect method name change.The function documentation should be updated to reflect the change from
SignUp
toCreateUser
for clarity.-// RunAdminSignUpTest runs the CreateUser test in admin. +// RunAdminCreateUserTest runs the CreateUser test in admin.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
Files selected for processing (12)
- admin/client.go (1 hunks)
- api/docs/yorkie/v1/admin.openapi.yaml (9 hunks)
- api/types/user_fields.go (1 hunks)
- api/types/user_fields_test.go (1 hunks)
- api/yorkie/v1/admin.proto (3 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- server/backend/database/memory/database.go (1 hunks)
- server/rpc/admin_server.go (2 hunks)
- server/rpc/interceptors/admin.go (1 hunks)
- server/rpc/testcases/testcases.go (2 hunks)
- server/users/users.go (2 hunks)
- test/integration/user_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (5)
- api/docs/yorkie/v1/admin.openapi.yaml
- api/types/user_fields.go
- server/backend/database/memory/database.go
- server/rpc/interceptors/admin.go
- server/users/users.go
Additional context used
GitHub Check: build
api/yorkie/v1/v1connect/admin.connect.go
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
GitHub Check: bench
api/yorkie/v1/v1connect/admin.connect.go
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
GitHub Check: sharding_test
api/yorkie/v1/v1connect/admin.connect.go
[failure] 422-422:
duplicate case AdminServiceCreateUserProcedure (constant "/yorkie.v1.AdminService/CreateUser" of type string) in expression switch
Additional comments not posted (29)
test/integration/user_test.go (3)
46-46
: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
CreateUser
match the new name.Verification successful
All method calls to
CreateUser
are consistent with the new name.The verification confirms that all occurrences of
CreateUser
match the new name across the codebase.
server/users/users.go
server/rpc/admin_server.go
server/rpc/testcases/testcases.go
server/rpc/interceptors/admin.go
server/backend/database/database.go
test/integration/user_test.go
server/backend/database/mongo/client.go
server/backend/database/memory/database.go
server/backend/database/testcases/testcases.go
admin/client.go
api/yorkie/v1/admin.pb.go
api/yorkie/v1/v1connect/admin.connect.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `CreateUser` match the new name. # Test: Search for the method usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'CreateUser'Length of output: 23349
43-43
: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
CreateUser
match the new name.Verification successful
The method usage of
CreateUser
is consistent across the codebase.The renaming from
SignUp
toCreateUser
has been correctly applied throughout the codebase.
- All instances of the method call use
CreateUser
.- No remaining references to the old method name
SignUp
were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `CreateUser` match the new name. # Test: Search for the method usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'CreateUser'Length of output: 23349
49-49
: LGTM! But verify the method usage in the codebase.The code changes are approved.
However, ensure that all method calls to
CreateUser
match the new name.Verification successful
All instances of
CreateUser
match the expected usage.The method
CreateUser
is consistently used across the codebase, and there are no discrepancies in its naming.
server/users/users.go
test/integration/user_test.go
server/rpc/admin_server.go
server/rpc/testcases/testcases.go
server/rpc/interceptors/admin.go
server/backend/database/database.go
server/backend/database/memory/database.go
server/backend/database/mongo/client.go
server/backend/database/testcases/testcases.go
admin/client.go
api/yorkie/v1/admin.pb.go
api/yorkie/v1/v1connect/admin.connect.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `CreateUser` match the new name. # Test: Search for the method usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'CreateUser'Length of output: 23349
api/types/user_fields_test.go (7)
41-41
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
LGTM! All struct instances of
UserFields
match the new name.The verification confirms that all instances of
UserFields
in the codebase are consistent with the new name.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
48-48
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
Verification Successful: All instances of
UserFields
match the new name.The struct
UserFields
is consistently used across the codebase without any discrepancies.
server/rpc/admin_server.go
api/types/user_fields_test.go
api/types/user_fields.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
69-69
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
Verification Successful: Struct Usage Consistent
All instances of the
UserFields
struct match the new name across the codebase.
server/rpc/admin_server.go
api/types/user_fields_test.go
api/types/user_fields.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
55-55
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
All instances of
UserFields
match the new name.The struct
UserFields
is consistently used across the codebase without any discrepancies in naming.
server/rpc/admin_server.go
api/types/user_fields.go
api/types/user_fields_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
62-62
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
Verification successful: All instances of
UserFields
match the expected name.
server/rpc/admin_server.go
api/types/user_fields.go
api/types/user_fields_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
76-76
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
Verification successful: All instances of
UserFields
are consistent.
- The struct
UserFields
is used consistently across the codebase without any indication of a new name.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
83-83
: LGTM! But verify the struct usage in the codebase.The code changes are approved.
However, ensure that all struct instances of
UserFields
match the new name.Verification successful
The script output shows multiple instances of
UserFields
in various files. To confirm if there has been a name change, we need to verify the definition of theUserFields
struct. Let's search for the struct definition to see if it has a new name.
Verified: The struct name
UserFields
has not changed, and all instances in the codebase are consistent with this name.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct instances of `UserFields` match the new name. # Test: Search for the struct usage. Expect: Only occurrences of the new name. rg --type go -A 5 $'UserFields'Length of output: 4169
Script:
#!/bin/bash # Description: Verify the definition of the UserFields struct to check for any name changes. # Search for the definition of the UserFields struct. rg --type go 'type UserFields struct'Length of output: 89
api/yorkie/v1/admin.proto (11)
60-63
: LGTM!The code changes are approved.
65-67
: LGTM!The code changes are approved.
78-81
: LGTM!The code changes are approved.
83-84
: LGTM!The code changes are approved.
86-89
: LGTM!The code changes are approved.
92-93
: LGTM!The code changes are approved.
Line range hint
54-57
:
LGTM!The code changes are approved.
59-59
: LGTM!The code changes are approved.
31-31
: LGTM! But verify the RPC usage in the codebase.The code changes are approved.
However, ensure that all RPC calls to
CreateUser
match the new name.Verification successful
Let's update the shell script to search for the
CreateUser
RPC in all.proto
files without specifying the file type.
LGTM! But verify the RPC usage in the codebase.
The code changes are approved.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all RPC calls to `CreateUser` match the new name. # Test: Search for the RPC usage. Expect: Only occurrences of the new name. rg --type proto -A 5 $'CreateUser'Length of output: 63
Script:
#!/bin/bash # Description: Verify all RPC calls to `CreateUser` match the new name. # Test: Search for the RPC usage. Expect: Only occurrences of the new name. rg 'CreateUser' --glob '*.proto' -A 5Length of output: 1167
33-33
: LGTM! But verify the RPC usage in the codebase.The code changes are approved.
However, ensure that all RPC calls to
DeleteAccount
match the new name.Verification successful
RPC usage for
DeleteAccount
is consistent.The search results show that the
DeleteAccount
RPC and its related request/response messages are defined inapi/yorkie/v1/admin.proto
, and there are no other occurrences in the.proto
files.
api/yorkie/v1/admin.proto
:rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {}
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all RPC calls to `DeleteAccount` match the new name. # Test: Search for the RPC usage. Expect: Only occurrences of the new name. rg --type proto -A 5 $'DeleteAccount'Length of output: 66
Script:
#!/bin/bash # Description: Verify all RPC calls to `DeleteAccount` match the new name. # Test: Search for the RPC usage in .proto files. Expect: Only occurrences of the new name. rg --glob '*.proto' -A 5 'DeleteAccount'Length of output: 1063
34-34
: LGTM! But verify the RPC usage in the codebase.The code changes are approved.
However, ensure that all RPC calls to
ChangePassword
match the new name.Verification successful
Verification Complete: RPC usage of
ChangePassword
is consistent across the codebase.The
ChangePassword
RPC call is used in multiple files, includingserver/users/users.go
,server/rpc/admin_server.go
, and others. All occurrences match the new name and implementation inadmin.proto
.
server/users/users.go
server/rpc/admin_server.go
server/rpc/interceptors/admin.go
server/backend/database/database.go
server/backend/database/mongo/client.go
server/backend/database/memory/database.go
api/yorkie/v1/admin.proto
api/yorkie/v1/admin.pb.go
api/yorkie/v1/v1connect/admin.connect.go
api/docs/yorkie/v1/admin.openapi.yaml
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all RPC calls to `ChangePassword` match the new name. # Test: Search for the RPC usage. Expect: Only occurrences of the new name. rg --type proto -A 5 $'ChangePassword'Length of output: 67
Script:
#!/bin/bash # Description: Verify all RPC calls to `ChangePassword` match the new name. # Find all .proto files and search for the RPC usage. fd -e proto -x rg 'ChangePassword' {}Length of output: 184
Script:
#!/bin/bash # Description: Verify all RPC calls to `ChangePassword` match the new name. # Search for the RPC usage in all file types. rg 'ChangePassword'Length of output: 7270
server/rpc/admin_server.go (2)
131-156
: LGTM! Verify the implementation of called functions.The
ChangePassword
method is well-structured, with proper error handling and validation. Ensure that theusers.IsCorrectPassword
andusers.ChangePassword
functions are correctly implemented and handle errors appropriately.Verification successful
Verification successful.
The
IsCorrectPassword
andChangePassword
functions are correctly implemented with proper error handling.
IsCorrectPassword
retrieves user info, compares the hashed password, and returns the user info if the password matches.ChangePassword
hashes the new password and updates it in the database.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `users.IsCorrectPassword` and `users.ChangePassword`. # Test: Search for the function definitions. Expect: Correct implementation with proper error handling. rg --type go -A 10 $'func IsCorrectPassword' rg --type go -A 10 $'func ChangePassword'Length of output: 1035
Script:
#!/bin/bash # Fetch the complete implementation of `IsCorrectPassword` function. rg --type go -A 20 'func IsCorrectPassword' server/users/users.go # Fetch the complete implementation of `ChangePassword` function. rg --type go -A 20 'func ChangePassword' server/users/users.goLength of output: 854
108-128
: LGTM! Verify the implementation of called functions.The
DeleteAccount
method is well-structured, with proper error handling and validation. Ensure that theusers.IsCorrectPassword
andusers.DeleteAccountByName
functions are correctly implemented and handle errors appropriately.Verification successful
Verified: The
DeleteAccount
method inadmin_server.go
is well-structured, with proper error handling and validation. Bothusers.IsCorrectPassword
andusers.DeleteAccountByName
are correctly implemented and handle errors appropriately.
IsCorrectPassword
retrieves user info and compares the provided password with the stored hash.DeleteAccountByName
deletes the user info from the database and handles any errors that may arise.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `users.IsCorrectPassword` and `users.DeleteAccountByName`. # Test: Search for the function definitions. Expect: Correct implementation with proper error handling. rg --type go -A 10 $'func IsCorrectPassword' rg --type go -A 10 $'func DeleteAccountByName'Length of output: 988
Script:
#!/bin/bash # Description: Retrieve the full implementation of `users.IsCorrectPassword` and `users.DeleteAccountByName`. # Fetch the complete implementation of `IsCorrectPassword`. rg --type go -A 20 'func IsCorrectPassword' server/users/users.go # Fetch the complete implementation of `DeleteAccountByName`. rg --type go -A 20 'func DeleteAccountByName' server/users/users.goLength of output: 936
api/yorkie/v1/v1connect/admin.connect.go (5)
143-152
: LGTM! Ensure correct initialization of new clients.The
NewAdminServiceClient
function initializes clients for the new RPC procedures. Verify their correct initialization.Verification successful
Verified: Correct initialization of new clients.
The
NewAdminServiceClient
function correctly initializes clients for the new RPC proceduresdeleteAccount
andchangePassword
.
deleteAccount
client initialized withconnect.NewClient[v1.DeleteAccountRequest, v1.DeleteAccountResponse]
changePassword
client initialized withconnect.NewClient[v1.ChangePasswordRequest, v1.ChangePasswordResponse]
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the initialization of new clients in `NewAdminServiceClient`. # Test: Search for the client initialization. Expect: Correct initialization in the function. rg --type go -A 10 $'connect.NewClient'Length of output: 9805
216-217
: LGTM! Ensure correct integration of new clients.The
adminServiceClient
struct includes new fields for theDeleteAccount
andChangePassword
clients. Verify their correct integration.Verification successful
LGTM! The
deleteAccount
andchangePassword
clients are correctly integrated into theadminServiceClient
struct.The new clients are properly added and utilized in the respective methods, ensuring their correct integration.
deleteAccount
client initialization and usage found.changePassword
client initialization and usage found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of new clients in `adminServiceClient`. # Test: Search for the client fields. Expect: Correct integration in the struct. rg --type go -A 5 $'deleteAccount' rg --type go -A 5 $'changePassword'Length of output: 3780
57-62
: LGTM! Ensure correct integration of new RPC procedures.The new RPC procedures
DeleteAccount
andChangePassword
enhance theAdminService
. Verify their correct integration.Verification successful
LGTM! The new RPC procedures
DeleteAccount
andChangePassword
are correctly integrated.The integration of the new RPC procedures
DeleteAccount
andChangePassword
enhances theAdminService
. The procedures are well-defined and implemented across various files, ensuring proper functionality.
server/rpc/admin_server.go
: Implementation ofDeleteAccount
andChangePassword
.server/users/users.go
: Supporting functions forDeleteAccount
andChangePassword
.api/yorkie/v1/admin.pb.go
: Definitions for request and response messages.api/yorkie/v1/v1connect/admin.connect.go
: Client-side and server-side handlers for the procedures.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of new RPC procedures. # Test: Search for the procedure usage. Expect: Correct integration in the service. rg --type go -A 5 $'DeleteAccount' rg --type go -A 5 $'ChangePassword'Length of output: 34678
103-104
: LGTM! Ensure correct implementation of new methods.The new methods
DeleteAccount
andChangePassword
enhance theAdminServiceClient
interface. Verify their correct implementation.Verification successful
The methods
DeleteAccount
andChangePassword
are correctly implemented in theadminServiceClient
.
DeleteAccount
method implementation found inapi/yorkie/v1/v1connect/admin.connect.go
.ChangePassword
method implementation found inapi/yorkie/v1/v1connect/admin.connect.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of new methods in `AdminServiceClient`. # Test: Search for the method definitions. Expect: Correct implementation in the client. rg --type go -A 10 $'func (c *adminServiceClient) DeleteAccount' rg --type go -A 10 $'func (c *adminServiceClient) ChangePassword'Length of output: 132
Script:
#!/bin/bash # Description: Verify the implementation of new methods in `AdminServiceClient`. # Test: Search for the method definitions more broadly. rg 'func (c \*adminServiceClient) DeleteAccount' --type go -A 10 rg 'func (c \*adminServiceClient) ChangePassword' --type go -A 10Length of output: 134
Script:
#!/bin/bash # Description: Verify the presence of any references to `DeleteAccount` and `ChangePassword` methods in the codebase. # Test: Search for references to the methods. rg 'DeleteAccount' --type go rg 'ChangePassword' --type goLength of output: 10493
473-479
: LGTM! Ensure appropriate error messages for unimplemented methods.The
UnimplementedAdminServiceHandler
struct includes unimplemented methods forDeleteAccount
andChangePassword
, ensuring appropriate error messages.server/rpc/testcases/testcases.go (1)
649-649
: EnsureCreateUser
method aligns with intended functionality.Verify that the
CreateUser
method correctly replaces theSignUp
method and that the test cases remain valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Outside diff range, codebase verification and nitpick comments (3)
api/docs/yorkie/v1/admin.openapi.yaml (3)
13-24
: Ensure the description field is filled.The description field for the
ChangeUserPassword
endpoint is currently empty. Providing a meaningful description enhances the API documentation.- description: "" + description: "Endpoint to change a user's password."
37-48
: Ensure the description field is filled.The description field for the
CreateUser
endpoint is currently empty. Providing a meaningful description enhances the API documentation.- description: "" + description: "Endpoint to create a new user."
49-60
: Ensure the description field is filled.The description field for the
DeleteAccount
endpoint is currently empty. Providing a meaningful description enhances the API documentation.- description: "" + description: "Endpoint to delete a user account."
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
Files selected for processing (9)
- api/docs/yorkie/v1/admin.openapi.yaml (9 hunks)
- api/yorkie/v1/admin.proto (3 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- server/backend/database/database.go (1 hunks)
- server/backend/database/memory/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
- server/rpc/admin_server.go (2 hunks)
- server/rpc/interceptors/admin.go (1 hunks)
- server/users/users.go (2 hunks)
Files skipped from review as they are similar to previous changes (5)
- api/yorkie/v1/admin.proto
- server/backend/database/database.go
- server/backend/database/memory/database.go
- server/rpc/interceptors/admin.go
- server/users/users.go
Additional context used
GitHub Check: bench
server/rpc/admin_server.go
[failure] 134-134:
undefined: api.ChangePasswordRequest
[failure] 135-135:
undefined: api.ChangePasswordResponse
[failure] 156-156:
undefined: api.ChangePasswordResponse
GitHub Check: sharding_test
server/rpc/admin_server.go
[failure] 134-134:
undefined: api.ChangePasswordRequest
[failure] 135-135:
undefined: api.ChangePasswordResponse
[failure] 156-156:
undefined: api.ChangePasswordResponse
GitHub Check: build
server/rpc/admin_server.go
[failure] 134-134:
undefined: api.ChangePasswordRequest
[failure] 135-135:
undefined: api.ChangePasswordResponse
[failure] 156-156:
undefined: api.ChangePasswordResponse (typecheck)
[failure] 134-134:
undefined: api.ChangePasswordRequest
[failure] 135-135:
undefined: api.ChangePasswordResponse
[failure] 156-156:
undefined: api.ChangePasswordResponse) (typecheck)
[failure] 134-134:
undefined: api.ChangePasswordRequest
[failure] 135-135:
undefined: api.ChangePasswordResponse
Additional comments not posted (7)
api/yorkie/v1/v1connect/admin.connect.go (1)
101-101
: LGTM!The
CreateUser
procedure is correctly implemented.Also applies to: 237-239
api/docs/yorkie/v1/admin.openapi.yaml (6)
17-17
: Verify the schema reference for the request body.Ensure that
#/components/requestBodies/yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordRequest
is correctly defined in the components section.Verification successful
Schema reference for the request body is correctly defined.
The schema
#/components/requestBodies/yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordRequest
is correctly defined and references the valid schema#/components/schemas/yorkie.v1.ChangeUserPasswordRequest
, which includes the necessary properties.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the request body of ChangeUserPassword endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordRequest'Length of output: 374
Script:
#!/bin/bash # Description: Locate and display the definition of the schema reference for the request body of ChangeUserPassword endpoint. # Search for the definition of the schema in the components section. rg --type yaml -A 10 'yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 589
Script:
#!/bin/bash # Description: Locate and display the definition of the schema 'yorkie.v1.ChangeUserPasswordRequest' in the components section. # Search for the definition of the schema in the components section. rg --type yaml -A 10 'yorkie.v1.ChangeUserPasswordRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 870
20-20
: Verify the schema reference for the response body.Ensure that
#/components/responses/yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordResponse
is correctly defined in the components section.Verification successful
The schema reference for the response body is correctly defined.
The
#/components/responses/yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordResponse
reference and its corresponding schemayorkie.v1.ChangeUserPasswordResponse
are properly defined in thecomponents
section of theadmin.openapi.yaml
file.
- The response reference is located in
components/responses
.- The schema definition is located in
components/schemas
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the response body of ChangeUserPassword endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordResponse'Length of output: 375
Script:
#!/bin/bash # Description: Extract and display the definition of yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordResponse from the components/responses section. # Extract the definition of the specified schema reference. rg -A 10 'yorkie.v1.AdminService.ChangeUserPassword.yorkie.v1.ChangeUserPasswordResponse:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 583
Script:
#!/bin/bash # Description: Extract and display the definition of yorkie.v1.ChangeUserPasswordResponse from the components/schemas section. # Extract the definition of the specified schema reference. rg -A 10 'yorkie.v1.ChangeUserPasswordResponse:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 863
56-56
: Verify the schema reference for the response body.Ensure that
#/components/responses/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse
is correctly defined in the components section.Verification successful
The schema reference for the response body is correctly defined.
- The reference
#/components/responses/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse
exists and correctly points to the schemayorkie.v1.DeleteAccountResponse
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the response body of DeleteAccount endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse'Length of output: 345
Script:
#!/bin/bash # Description: Extract the definition of the schema reference for the response body of DeleteAccount endpoint. # Extract the definition of the schema reference. rg -A 10 'yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountResponse' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 990
Script:
#!/bin/bash # Description: Extract the definition of the schema referenced by DeleteAccountResponse. # Extract the definition of the schema reference. rg -A 10 'yorkie.v1.DeleteAccountResponse' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 1546
44-44
: Verify the schema reference for the response body.Ensure that
#/components/responses/yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserResponse
is correctly defined in the components section.Verification successful
The schema reference for the response body is correctly defined.
- The reference
#/components/responses/yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserResponse
is present in the components section.- The referenced schema
#/components/schemas/yorkie.v1.CreateUserResponse
is also properly defined.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the response body of CreateUser endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserResponse'Length of output: 327
Script:
#!/bin/bash # Description: Extract the full definition of the schema reference for the response body of CreateUser endpoint. # Test: Search for the full definition of the schema reference. rg -A 10 'yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserResponse:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 535
Script:
#!/bin/bash # Description: Verify the schema reference for yorkie.v1.CreateUserResponse. # Test: Search for the definition of yorkie.v1.CreateUserResponse. rg -A 10 'yorkie.v1.CreateUserResponse:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 821
41-41
: Verify the schema reference for the request body.Ensure that
#/components/requestBodies/yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest
is correctly defined in the components section.Verification successful
The schema reference for the request body is correctly defined.
The
#/components/requestBodies/yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest
reference points to a valid schema definition in the components section.
- The schema definition for
yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest
correctly references#/components/schemas/yorkie.v1.CreateUserRequest
.- The
yorkie.v1.CreateUserRequest
schema is properly defined with the necessary properties.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the request body of CreateUser endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest'Length of output: 326
Script:
#!/bin/bash # Description: Extract and display the schema definition for yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest # Extract the relevant section from the YAML file rg -A 10 'yorkie.v1.AdminService.CreateUser.yorkie.v1.CreateUserRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 529
Script:
#!/bin/bash # Description: Verify the schema definition for yorkie.v1.CreateUserRequest # Search for the schema definition in the YAML file rg -A 10 'yorkie.v1.CreateUserRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 792
53-53
: Verify the schema reference for the request body.Ensure that
#/components/requestBodies/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest
is correctly defined in the components section.Verification successful
The schema reference for the request body is correctly defined.
The reference
#/components/requestBodies/yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest
and its associated schemayorkie.v1.DeleteAccountRequest
are both properly structured and complete.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema reference for the request body of DeleteAccount endpoint. # Test: Search for the schema definition. Expect: Correct definition. rg --type yaml $'yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest'Length of output: 344
Script:
#!/bin/bash # Description: Extract and display the schema definition for the request body of DeleteAccount endpoint. # Extract the schema definition for detailed inspection. rg -A 10 'yorkie.v1.AdminService.DeleteAccount.yorkie.v1.DeleteAccountRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 543
Script:
#!/bin/bash # Description: Verify the schema definition for yorkie.v1.DeleteAccountRequest. # Search for the schema definition to ensure it is correctly defined. rg -A 10 'yorkie.v1.DeleteAccountRequest:' api/docs/yorkie/v1/admin.openapi.yamlLength of output: 806
@gusah009 There seems to be lint error causing CI to fail. Could you please lint it again? |
dadbca8
to
8168ab6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (7)
api/docs/yorkie/v1/admin.openapi.yaml (7)
14-15
: Add a description for theChangeUserPassword
endpoint.The description field is currently empty. Adding a description will improve the documentation.
- description: "" + description: "Allows an admin to change a user's password."
39-40
: Add a description for theCreateUser
endpoint.The description field is currently empty. Adding a description will improve the documentation.
- description: "" + description: "Allows an admin to create a new user."
51-52
: Add a description for theDeleteUser
endpoint.The description field is currently empty. Adding a description will improve the documentation.
- description: "" + description: "Allows an admin to delete a user."
705-723
: Add descriptions for the fields inChangeUserPasswordRequest
.The descriptions for the fields are currently empty. Adding descriptions will improve the documentation.
- description: "" + description: "The current password of the user." - description: "" + description: "The new password for the user." - description: "" + description: "The username of the user."
754-767
: Add descriptions for the fields inCreateUserRequest
.The descriptions for the fields are currently empty. Adding descriptions will improve the documentation.
- description: "" + description: "The password for the new user." - description: "" + description: "The username for the new user."
770-779
: Add a description for theuser
field inCreateUserResponse
.The description for the
user
field is currently empty. Adding a description will improve the documentation.- description: "" + description: "The newly created user."
782-795
: Add descriptions for the fields inDeleteUserRequest
.The descriptions for the fields are currently empty. Adding descriptions will improve the documentation.
- description: "" + description: "The password for the user to be deleted." - description: "" + description: "The username of the user to be deleted."
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
Files selected for processing (12)
- api/docs/yorkie/v1/admin.openapi.yaml (9 hunks)
- api/yorkie/v1/admin.proto (3 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- server/backend/database/database.go (1 hunks)
- server/backend/database/memory/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
- server/rpc/admin_server.go (3 hunks)
- server/rpc/interceptors/admin.go (1 hunks)
- server/rpc/server_test.go (1 hunks)
- server/rpc/testcases/testcases.go (2 hunks)
- server/users/users.go (2 hunks)
- test/sharding/server_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
- test/sharding/server_test.go
Files skipped from review as they are similar to previous changes (5)
- api/yorkie/v1/admin.proto
- server/backend/database/database.go
- server/backend/database/memory/database.go
- server/rpc/interceptors/admin.go
- server/users/users.go
Additional context used
GitHub Check: build
server/rpc/testcases/testcases.go
[failure] 647-647:
string123!
has 3 occurrences, make it a constant (goconst)
Additional comments not posted (18)
server/rpc/server_test.go (3)
178-180
: LGTM!The test case name change from "admin signup test" to "admin create user test" accurately reflects the functionality being tested.
186-188
: LGTM!The new test case for deleting a user (
admin delete user test
) is correctly named and calls the appropriate function.
190-192
: LGTM!The new test case for changing a user's password (
admin change password test
) is correctly named and calls the appropriate function.server/rpc/admin_server.go (3)
75-93
: LGTM!The
CreateUser
method correctly validates the user fields and creates a new user. Error handling is also appropriately managed.
120-141
: LGTM!The
DeleteUser
method correctly validates the user's password and deletes the user account. Error handling is also appropriately managed.
143-169
: LGTM!The
ChangeUserPassword
method correctly validates the new password fields, checks the current password, and updates the password. Error handling is also appropriately managed.api/yorkie/v1/v1connect/admin.connect.go (6)
53-54
: LGTM!The
AdminServiceCreateUserProcedure
is correctly defined with its fully-qualified name.
57-58
: LGTM!The
AdminServiceDeleteUserProcedure
is correctly defined with its fully-qualified name.
60-61
: LGTM!The
AdminServiceChangeUserPasswordProcedure
is correctly defined with its fully-qualified name.
100-101
: LGTM!The
CreateUser
method is correctly added to theAdminServiceClient
interface and implemented in theadminServiceClient
struct.Also applies to: 235-238
102-103
: LGTM!The
DeleteUser
method is correctly added to theAdminServiceClient
interface and implemented in theadminServiceClient
struct.Also applies to: 245-248
103-103
: LGTM!The
ChangeUserPassword
method is correctly added to theAdminServiceClient
interface and implemented in theadminServiceClient
struct.Also applies to: 250-253
server/rpc/testcases/testcases.go (3)
734-801
: LGTM! But verify the function usage in the codebase.The new function
RunAdminChangePasswordTest
is well-structured and includes necessary error handling.However, ensure that the function is correctly integrated and used within the codebase.
Verification successful
The function
RunAdminChangePasswordTest
is correctly integrated and used within the codebase.
- It is invoked in the
server/rpc/server_test.go
file, indicating proper integration into the test suite.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the function usage of `RunAdminChangePasswordTest` in the codebase. # Test: Search for the function usage. Expect: Appropriate integration and usage. rg --type go -A 5 $'RunAdminChangePasswordTest'Length of output: 908
696-732
: LGTM! But verify the function usage in the codebase.The new function
RunAdminDeleteUserTest
is well-structured and includes necessary error handling.However, ensure that the function is correctly integrated and used within the codebase.
Verification successful
The function
RunAdminDeleteUserTest
is correctly integrated and used within the codebase.
- The function is utilized in
server/rpc/server_test.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the function usage of `RunAdminDeleteUserTest` in the codebase. # Test: Search for the function usage. Expect: Appropriate integration and usage. rg --type go -A 5 $'RunAdminDeleteUserTest'Length of output: 859
641-661
: LGTM! But verify the function usage in the codebase.The renaming from
RunAdminSignUpTest
toRunAdminCreateUserTest
and the update fromSignUp
toCreateUser
are appropriate.However, ensure that all function calls to
RunAdminCreateUserTest
match the new name and method call.Verification successful
Verification successful!
The function
RunAdminCreateUserTest
is correctly used in the codebase with the new name and method call.
server/rpc/server_test.go
test/sharding/server_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `RunAdminCreateUserTest` match the new name and method call. # Test: Search for the function usage. Expect: Only occurrences of the new name and method call. rg --type go -A 5 $'RunAdminCreateUserTest'Length of output: 1181
Tools
GitHub Check: build
[failure] 647-647:
string123!
has 3 occurrences, make it a constant (goconst)server/backend/database/mongo/client.go (1)
660-673
: Enhance error handling and logging.Consider adding more specific error messages and logging for better traceability.
updateResult, err := c.collection(ColUsers).UpdateOne(ctx, bson.M{"username": username}, bson.M{"$set": bson.M{"hashed_password": hashedNewPassword}}, ) if err != nil { + logging.DefaultLogger().Errorf("Failed to update password for user: %s, error: %v", username, err) return fmt.Errorf("failed to update password for user %s: %w", username, err) } if updateResult.ModifiedCount == 0 { + logging.DefaultLogger().Warnf("No user found to update password with username: %s", username) return fmt.Errorf("no user found with username %s", username) } +logging.DefaultLogger().Infof("Password updated for user: %s", username) return nilLikely invalid or redundant comment.
api/docs/yorkie/v1/admin.openapi.yaml (2)
183-183
: Deprecation notice is clear and correctly references the new functionality.The deprecation notice for the
SignUp
endpoint is clear and correctly references theCreateUser
functionality.
726-729
: Confirm ifChangeUserPasswordResponse
is intended to be empty.The schema has no properties. If no properties are needed, this should be explicitly stated.
- description: "" + description: "Response schema for ChangeUserPassword. No properties are needed."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- server/rpc/testcases/testcases.go (2 hunks)
- test/helper/helper.go (1 hunks)
Additional comments not posted (4)
test/helper/helper.go (1)
67-67
: LGTM! But verify the usage of the new variable.The new variable
AdminPasswordForCreateUser
is defined correctly. Ensure that it is used appropriately in the codebase.Verification successful
LGTM! The new variable
AdminPasswordForCreateUser
is used appropriately in the codebase.The variable is used in the functions
RunAdminCreateUserTest
,RunAdminDeleteUserTest
, andRunAdminChangePasswordTest
for setting theadminPassword
in user creation tests.
server/rpc/testcases/testcases.go
: Lines whereAdminPasswordForCreateUser
is used.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new variable `AdminPasswordForCreateUser`. # Test: Search for the usage of the new variable. Expect: Appropriate usage in the codebase. rg --type go 'AdminPasswordForCreateUser'Length of output: 385
Script:
#!/bin/bash # Description: Extract the relevant lines from `server/rpc/testcases/testcases.go` to review the context of the usage of `AdminPasswordForCreateUser`. # Extract 5 lines before and after each occurrence of `AdminPasswordForCreateUser` for context. rg --type go 'AdminPasswordForCreateUser' -A 5 -B 5 server/rpc/testcases/testcases.goLength of output: 1046
server/rpc/testcases/testcases.go (3)
641-661
: LGTM! The renaming and method call update are appropriate.The function
RunAdminSignUpTest
has been correctly renamed toRunAdminCreateUserTest
, and the internal method call has been updated fromSignUp
toCreateUser
.
696-731
: LGTM! The new test function is comprehensive.The function
RunAdminDeleteUserTest
correctly tests the deletion of a user and ensures appropriate error handling for non-existent users.
734-801
: LGTM! The new test function is comprehensive.The function
RunAdminChangePasswordTest
correctly tests the password change process and ensures appropriate error handling for invalid operations.
@krapie hello. I agree with all of your suggestions in the comments, so I've made the following changes.
In addition, I also included the review. Thank you for your careful review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm a bit confused by the word RunAdminCreateUserTest
. Does this mean admin can create other user or create itself(admin)? RunAdminSignUpTest
makes more sense in terms of creating itself(admin).
Sorry, but I think we should reconsider which word to use. Using the word User
may confuse others between admin creating user(not admin), or creating itself(admin).
Any ideas? @hackerwins
Also, I did not get what below comment means:
|
@krapie Anyway, that means, what it means is that I want to refactor the duplicated validation strings like type SignupFields struct {
// Username is the name of user.
Username *string `bson:"username" validate:"required,min=2,max=30,slug"`
// Password is the password of user.
Password *string `bson:"password" validate:"required,min=8,max=30,alpha_num_special"`
}
type ChangePasswordFields struct {
// Username is the name of user.
Username *string `bson:"username" validate:"required,min=2,max=30,slug"`
// NewPassword is the new password of user
NewPassword *string `bson:"new_password" validate:"required,min=8,max=30,alpha_num_special"`
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- server/backend/database/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- server/backend/database/database.go
- server/backend/database/mongo/client.go
@gusah009 How about changing the word It will look something like below: service AdminService {
rpc LogIn(LogInRequest) returns (LogInResponse) {}
rpc CreateAccount(CreateAccountRequest) returns (CreateAccountResponse) {}
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {}
rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordResponse) {}
} |
@krapie Oh, that's a good idea. I'll do it right away. Well, then I'll change the |
@gusah009 Hmm. I'm not sure about changing
|
@krapie Looking at it like this, I don’t think I need to change the username. Thank you for your good advice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
Outside diff range, codebase verification and nitpick comments (5)
test/integration/account_test.go (1)
43-49
: Ensure consistency by removing deprecatedSignUp
referencesThe transition to using
CreateAccount
is incomplete. There are still several references to the deprecatedSignUp
method that need to be addressed:
server/rpc/admin_server.go
: Function definition and comments.server/rpc/interceptors/admin.go
: Interceptor checks.api/yorkie/v1/admin.pb.go
: Protobuf message types and descriptors.api/yorkie/v1/v1connect/admin.connect.go
: RPC handlers and client definitions.Please update these references to ensure consistency throughout the codebase.
Analysis chain
LGTM! Updating the method calls enhances clarity.
The changes to use
CreateAccount
instead ofSignUp
align with the new terminology and improve the readability of the test cases.However, ensure that all method calls to
CreateAccount
are consistent throughout the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `CreateAccount` are consistent throughout the codebase. # Test: Search for the method usage. Expect: Only occurrences of the new method name. rg --type go -A 5 $'CreateAccount'Length of output: 25657
Script:
#!/bin/bash # Description: Verify if there are any remaining calls to the deprecated `SignUp` method in the codebase. # Test: Search for the deprecated method usage. Expect: No occurrences of the old method name. rg --type go -A 5 $'SignUp'Length of output: 16168
server/accounts/accounts.go (1)
Line range hint
55-68
: Add validation forusername
andpassword
.The function should validate the
username
andpassword
parameters before proceeding with the password check. This will ensure that the input data meets the required criteria and prevent potential issues with invalid data.+ if err := validateUsername(username); err != nil { + return nil, fmt.Errorf("invalid username: %w", err) + } + if err := validatePassword(password); err != nil { + return nil, fmt.Errorf("invalid password: %w", err) + }server/backend/database/database.go (2)
130-131
: Action Required: Update references toFindUserInfoByID
in test cases.The method
FindAccountInfoByID
has been correctly updated, but some test cases still refer to the old method nameFindUserInfoByID
. These references need to be updated to ensure consistency and validity of the tests.
server/backend/database/testcases/testcases.go
server/backend/database/mongo/client_test.go
server/backend/database/memory/database_test.go
#!/bin/bash # Description: Identify all instances of `FindUserInfoByID` in the codebase, focusing on test files. # Test: Search for the old method name in test files. rg --type go 'FindUserInfoByID'Analysis chain
Change Approved: Updated method to
FindAccountInfoByID
.The method name and return type changes align with the shift to account-centric terminology.
Verify that all calls to this method have been updated to match the new signature.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `FindAccountInfoByID` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'FindAccountInfoByID'Length of output: 4002
133-137
: Outdated Test Function Names: Update RequiredThe test functions still use the old names
RunFindUserInfoByNameTest
andRunListUserInfosTest
. Please update these test function names to reflect the new method names to maintain consistency.
server/backend/database/memory/database_test.go
: UpdateRunFindUserInfoByNameTest
toRunFindAccountInfoByNameTest
.server/backend/database/memory/database_test.go
: UpdateRunListUserInfosTest
toRunListAccountInfosTest
.server/backend/database/testcases/testcases.go
: UpdateRunFindUserInfoByNameTest
toRunFindAccountInfoByNameTest
.server/backend/database/testcases/testcases.go
: UpdateRunListUserInfosTest
toRunListAccountInfosTest
.server/backend/database/mongo/client_test.go
: UpdateRunFindUserInfoByNameTest
toRunFindAccountInfoByNameTest
.server/backend/database/mongo/client_test.go
: UpdateRunListUserInfosTest
toRunListAccountInfosTest
.test/sharding/mongo_client_test.go
: UpdateRunListUserInfosTest
toRunListAccountInfosTest
.Analysis chain
Change Approved: Updated methods to
FindAccountInfoByName
andListAccountInfos
.The method names and return type changes align with the shift to account-centric terminology.
Verify that all calls to these methods have been updated to match the new signatures.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `FindAccountInfoByName` and `ListAccountInfos` match the new signatures. # Test: Search for the function usage. Expect: Only occurrences of the new signatures. rg --type go -A 5 $'FindAccountInfoByName' rg --type go -A 5 $'ListAccountInfos'Length of output: 8444
server/backend/database/mongo/client.go (1)
Line range hint
123-154
:
Update error message to reflect account-centric model.The error message "upsert default user info" should be updated to "upsert default account info" for consistency.
if err != nil { return nil, fmt.Errorf("upsert default user info: %w", err) }should be:
if err != nil { return nil, fmt.Errorf("upsert default account info: %w", err) }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
api/yorkie/v1/resources.pb.go
is excluded by!**/*.pb.go
Files selected for processing (36)
- admin/client.go (1 hunks)
- api/converter/from_pb.go (1 hunks)
- api/converter/to_pb.go (1 hunks)
- api/docs/yorkie/v1/admin.openapi.yaml (12 hunks)
- api/docs/yorkie/v1/resources.openapi.yaml (2 hunks)
- api/types/account.go (1 hunks)
- api/types/account_fields.go (1 hunks)
- api/types/account_fields_test.go (1 hunks)
- api/yorkie/v1/admin.proto (5 hunks)
- api/yorkie/v1/resources.proto (1 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- cmd/yorkie/login.go (1 hunks)
- cmd/yorkie/server.go (1 hunks)
- design/presence.md (2 hunks)
- pkg/index/tree.go (1 hunks)
- server/accounts/accounts.go (4 hunks)
- server/accounts/context.go (1 hunks)
- server/backend/backend.go (1 hunks)
- server/backend/database/account_info.go (1 hunks)
- server/backend/database/client_info.go (1 hunks)
- server/backend/database/database.go (3 hunks)
- server/backend/database/memory/database.go (3 hunks)
- server/backend/database/memory/database_test.go (1 hunks)
- server/backend/database/memory/indexes.go (2 hunks)
- server/backend/database/mongo/client.go (5 hunks)
- server/backend/database/mongo/client_test.go (1 hunks)
- server/backend/database/mongo/indexes.go (3 hunks)
- server/backend/database/testcases/testcases.go (2 hunks)
- server/rpc/admin_server.go (16 hunks)
- server/rpc/connecthelper/status.go (2 hunks)
- server/rpc/interceptors/admin.go (6 hunks)
- server/rpc/server_test.go (1 hunks)
- server/rpc/testcases/testcases.go (2 hunks)
- test/helper/helper.go (1 hunks)
- test/integration/account_test.go (1 hunks)
- test/sharding/mongo_client_test.go (1 hunks)
Files skipped from review due to trivial changes (6)
- cmd/yorkie/login.go
- cmd/yorkie/server.go
- design/presence.md
- pkg/index/tree.go
- server/backend/database/memory/database_test.go
- test/sharding/mongo_client_test.go
Files skipped from review as they are similar to previous changes (6)
- admin/client.go
- api/docs/yorkie/v1/admin.openapi.yaml
- server/rpc/interceptors/admin.go
- server/rpc/server_test.go
- server/rpc/testcases/testcases.go
- test/helper/helper.go
Additional comments not posted (74)
api/types/account.go (1)
22-23
: LGTM! RenamingUser
toAccount
is consistent with the new functionality.The renaming aligns with the broader scope of the struct.
server/accounts/context.go (4)
17-17
: LGTM! Changing the package name toaccounts
aligns with the new functionality.The package name change is consistent with the shift to account-centric operations.
25-26
: LGTM! RenaminguserKey
toaccountKey
is consistent with the new functionality.The renaming aligns with the broader scope of the key type.
29-30
: LGTM! Updating the function signature to handle*types.Account
is consistent with the new functionality.The function correctly retrieves an
*types.Account
from the context.
34-35
: LGTM! Updating the function signature to handle*types.Account
is consistent with the new functionality.The function correctly sets an
*types.Account
into the context.api/types/account_fields.go (4)
24-25
: LGTM! RenamingSignupFields
toAccountFields
is consistent with the new functionality.The renaming aligns with the broader scope of the struct.
26-26
: LGTM! The updated comment accurately reflects the purpose of theUsername
field.The comment is consistent with the new struct name.
29-29
: LGTM! The updated comment accurately reflects the purpose of thePassword
field.The comment is consistent with the new struct name.
33-34
: LGTM! Updating the method to operate onAccountFields
is consistent with the new functionality.The method correctly validates the
AccountFields
struct.test/integration/account_test.go (2)
31-31
: LGTM! Renaming the test function enhances clarity.The renaming of
TestUser
toTestAccount
aligns with the new terminology and improves the readability of the test suite.
35-35
: LGTM! Renaming the test case enhances clarity.The renaming of the test case to "account test" aligns with the new terminology and improves the readability of the test suite.
api/types/account_fields_test.go (2)
41-83
: LGTM! Updating the struct name enhances clarity.The changes to use
AccountFields
instead ofSignupFields
align with the new terminology and improve the readability of the test cases.
34-34
: LGTM! Updating the struct name enhances clarity.The changes to use
AccountFields
instead ofSignupFields
align with the new terminology and improve the readability of the test cases.However, ensure that all struct usages of
AccountFields
are consistent throughout the codebase.Verification successful
Verification successful. The struct
AccountFields
is used consistently throughout the codebase.
server/rpc/admin_server.go
api/types/account_fields.go
api/types/account_fields_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all struct usages of `AccountFields` are consistent throughout the codebase. # Test: Search for the struct usage. Expect: Only occurrences of the new struct name. rg --type go -A 5 $'AccountFields'Length of output: 4824
server/backend/database/account_info.go (4)
33-34
: LGTM! Renaming the struct enhances clarity.The changes to use
AccountInfo
instead ofUserInfo
align with the new terminology and improve the readability of the code.
41-43
: LGTM! Renaming the function enhances clarity.The changes to use
NewAccountInfo
instead ofNewUserInfo
align with the new terminology and improve the readability of the code.
50-56
: LGTM! Updating the function enhances clarity.The changes to use
DeepCopy
forAccountInfo
instead ofUserInfo
align with the new terminology and improve the readability of the code.
64-66
: LGTM! Renaming the function enhances clarity.The changes to use
ToAccount
instead ofToUser
align with the new terminology and improve the readability of the code.However, ensure that all method calls to
ToAccount
are consistent throughout the codebase.Verification successful
Method
ToAccount
usage is consistent across the codebase.The
ToAccount
method is used correctly in all relevant places, and the deprecatedToUser
method is appropriately marked. No further action is needed.
server/accounts/accounts.go
server/rpc/admin_server.go
api/converter/to_pb.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `ToAccount` are consistent throughout the codebase. # Test: Search for the method usage. Expect: Only occurrences of the new method name. rg --type go -A 5 $'ToAccount'Length of output: 2787
server/accounts/accounts.go (1)
86-96
: LGTM!The function
GetAccountByID
looks good and is correctly implemented.server/backend/database/mongo/indexes.go (3)
31-32
: LGTM!The constant
ColAccounts
is correctly renamed and aligns with the new account-centric model.
48-48
: LGTM!The
Collections
variable is correctly updated to includeColAccounts
instead ofColUsers
.
80-80
: LGTM!The
collectionInfos
structure is correctly updated to includeColAccounts
instead ofColUsers
.api/yorkie/v1/admin.proto (8)
29-29
: Ensure clients are notified about the deprecation ofSignUp
.The
SignUp
RPC is marked as deprecated and will be replaced byCreateAccount
. Ensure that clients using this RPC are aware of the deprecation and have a migration path.
31-31
: LGTM! TheCreateAccount
RPC is a good addition.The introduction of the
CreateAccount
RPC aligns with the goal of enhancing account management.
33-34
: LGTM! TheDeleteAccount
andChangeAccountPassword
RPCs are essential additions.The introduction of the
DeleteAccount
andChangeAccountPassword
RPCs enhances the functionality of the AdminService.
60-63
: LGTM! TheCreateAccountRequest
message is well-defined.The
CreateAccountRequest
message includes the necessary fields for account creation.
65-67
: LGTM! TheCreateAccountResponse
message is well-defined.The
CreateAccountResponse
message includes the necessary field for the account creation response.
78-81
: LGTM! TheDeleteAccountRequest
message is well-defined.The
DeleteAccountRequest
message includes the necessary fields for account deletion.
86-90
: LGTM! TheChangeAccountPasswordRequest
message is well-defined.The
ChangeAccountPasswordRequest
message includes the necessary fields for changing account passwords.
92-93
: LGTM! TheChangeAccountPasswordResponse
message is appropriate.The
ChangeAccountPasswordResponse
message serves as a simple acknowledgment of the password change operation.server/backend/backend.go (1)
125-125
: Verify the existence and implementation ofEnsureDefaultAccountAndProject
.The function call is changed from
EnsureDefaultUserAndProject
toEnsureDefaultAccountAndProject
. Ensure that the renamed function exists and is correctly implemented.Verification successful
The function
EnsureDefaultAccountAndProject
exists and is implemented correctly.The function
EnsureDefaultAccountAndProject
is referenced and implemented in multiple files, including:
server/backend/database/mongo/client.go
server/backend/database/memory/database.go
The renaming from
EnsureDefaultUserAndProject
toEnsureDefaultAccountAndProject
is consistent with the shift in terminology from "User" to "Account".Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence and implementation of `EnsureDefaultAccountAndProject`. # Test: Search for the function implementation. Expect: The function should be implemented correctly. ast-grep --lang go --pattern $'func EnsureDefaultAccountAndProject($_, $_, $_, $_) ($_, $_, $_) { $$$ }'Length of output: 107
Script:
#!/bin/bash # Description: Verify the existence and implementation of `EnsureDefaultAccountAndProject`. # Test: Search for the function implementation without specifying parameters. ast-grep --lang go --pattern $'func EnsureDefaultAccountAndProject($$$) { $$$ }'Length of output: 83
Script:
#!/bin/bash # Description: Search for references to `EnsureDefaultAccountAndProject` in the codebase. # Test: Search for any references to the function name. rg 'EnsureDefaultAccountAndProject'Length of output: 1203
server/backend/database/memory/indexes.go (1)
23-23
: Verify that all references totblUsers
are updated totblAccounts
.The variable
tblUsers
is renamed totblAccounts
. Ensure that all references to the old variable name are updated.Verification successful
All references to
tblUsers
have been successfully updated totblAccounts
.The search results confirm that
tblAccounts
is used consistently across the codebase.
server/backend/database/memory/indexes.go
server/backend/database/memory/database.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all references to `tblUsers` are updated to `tblAccounts`. # Test: Search for the old variable name. Expect: No occurrences of `tblUsers`. rg --type go 'tblUsers'Length of output: 23
Script:
#!/bin/bash # Description: Verify that `tblAccounts` is used in place of `tblUsers`. # Test: Search for the new variable name. Expect: Occurrences of `tblAccounts`. rg --type go 'tblAccounts'Length of output: 1309
server/backend/database/client_info.go (1)
70-70
: Comment update approved.The change in the comment for the
Key
field from "users" to "accounts" aligns with the updated terminology.server/rpc/connecthelper/status.go (4)
56-56
: Addition ofdatabase.ErrAccountNotFound
approved.The addition of
database.ErrAccountNotFound
to theerrorToConnectCode
map with aconnect.CodeNotFound
status is consistent with the updated terminology.
61-61
: Addition ofdatabase.ErrAccountAlreadyExists
approved.The addition of
database.ErrAccountAlreadyExists
to theerrorToConnectCode
map with aconnect.CodeAlreadyExists
status is consistent with the updated terminology.
107-107
: Addition ofdatabase.ErrAccountNotFound
approved.The addition of
database.ErrAccountNotFound
to theerrorToCode
map with a string representation of "ErrAccountNotFound" is consistent with the updated terminology.
111-111
: Addition ofdatabase.ErrAccountAlreadyExists
approved.The addition of
database.ErrAccountAlreadyExists
to theerrorToCode
map with a string representation of "ErrAccountAlreadyExists" is consistent with the updated terminology.api/yorkie/v1/resources.proto (2)
274-274
: Deprecation comment forUser
approved.The deprecation comment for the
User
message is clear and indicates the transition to theAccount
message.
281-285
: NewAccount
message definition approved.The
Account
message mirrors the structure of the deprecatedUser
message and aligns with the updated terminology.server/backend/database/database.go (6)
35-36
: Change Approved: Updated error message toErrAccountNotFound
.The change aligns with the shift from user-centric to account-centric terminology.
41-42
: Change Approved: Updated error message toErrAccountAlreadyExists
.The change aligns with the shift from user-centric to account-centric terminology.
117-122
: Change Approved: Updated method toCreateAccountInfo
.The method name and return type changes align with the shift to account-centric terminology.
Verify that all calls to this method have been updated to match the new signature.
Verification successful
Change Approved: Updated method to
CreateAccountInfo
.The method name and return type changes align with the shift to account-centric terminology. All instances of
CreateAccountInfo
in the codebase have been updated to match the new signature.
server/accounts/accounts.go
server/backend/database/testcases/testcases.go
server/backend/database/mongo/client.go
server/backend/database/memory/database.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `CreateAccountInfo` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'CreateAccountInfo'Length of output: 2581
124-125
: Change Approved: Introduced methodDeleteAccountInfoByName
.The method aligns with the new account management functionalities.
Verify that the method is used correctly in the codebase.
Verification successful
Change Approved: Introduced method
DeleteAccountInfoByName
.The method aligns with the new account management functionalities and is used correctly and consistently across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `DeleteAccountInfoByName` in the codebase. # Test: Search for the method usage. Expect: Correct and consistent usage. rg --type go -A 5 $'DeleteAccountInfoByName'Length of output: 2011
127-128
: Change Approved: Introduced methodChangeAccountPassword
.The method aligns with the new account management functionalities.
Verify that the method is used correctly in the codebase.
Verification successful
Change Approved: Introduced method
ChangeAccountPassword
.The method aligns with the new account management functionalities and is consistently used across the codebase.
server/rpc/testcases/testcases.go
server/rpc/interceptors/admin.go
server/accounts/accounts.go
server/rpc/admin_server.go
server/backend/database/database.go
server/backend/database/memory/database.go
server/backend/database/mongo/client.go
api/yorkie/v1/admin.pb.go
api/yorkie/v1/v1connect/admin.connect.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `ChangeAccountPassword` in the codebase. # Test: Search for the method usage. Expect: Correct and consistent usage. rg --type go -A 5 $'ChangeAccountPassword'Length of output: 21116
89-96
: Change Approved: Updated method toEnsureDefaultAccountAndProject
.The method name and return type changes align with the shift to account-centric terminology.
Verify that all calls to this method have been updated to match the new signature.
server/rpc/admin_server.go (4)
53-73
: Deprecation Notice Approved:SignUp
method.The
SignUp
method is deprecated and will be replaced byCreateAccount
. The notice is clear, and the method remains functional.
143-169
: Change Approved: Introduced methodChangeAccountPassword
.The method validates the new password fields and calls
accounts.ChangeAccountPassword
. Ensure the validation and password change logic are correct.Verify that the method is used correctly in the codebase.
Verification successful
Change Approved: Introduced method
ChangeAccountPassword
.The method validates the new password fields and calls
accounts.ChangeAccountPassword
. The method is used correctly and consistently in the codebase.
- Verified usage in
server/rpc/admin_server.go
,server/rpc/server_test.go
,server/rpc/testcases/testcases.go
,server/rpc/interceptors/admin.go
,server/accounts/accounts.go
,server/backend/database/database.go
,server/backend/database/memory/database.go
,server/backend/database/mongo/client.go
,api/yorkie/v1/admin.pb.go
, andapi/yorkie/v1/v1connect/admin.connect.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `ChangeAccountPassword` in the codebase. # Test: Search for the method usage. Expect: Correct and consistent usage. rg --type go -A 5 $'ChangeAccountPassword'Length of output: 21116
120-141
: Change Approved: Introduced methodDeleteAccount
.The method validates the user's password and calls
accounts.DeleteAccountByName
. Ensure the validation and account deletion logic are correct.Verify that the method is used correctly in the codebase.
Verification successful
Verification Successful: Method
DeleteAccount
is used correctly in the codebase.The method
DeleteAccount
is properly implemented and tested across various files:
server/rpc/testcases/testcases.go
server/rpc/server_test.go
api/yorkie/v1/v1connect/admin.connect.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `DeleteAccount` in the codebase. # Test: Search for the method usage. Expect: Correct and consistent usage. rg --type go -A 5 $'DeleteAccount'Length of output: 20237
75-91
: Change Approved: Introduced methodCreateAccount
.The method validates account fields and calls
accounts.CreateAccount
. Ensure the validation and account creation logic are correct.Verify that the method is used correctly in the codebase.
Verification successful
Change Approved: Introduced method
CreateAccount
.The method validates account fields and calls
accounts.CreateAccount
. The usage of theCreateAccount
method is consistent and correct across the codebase.
- Verified in test/integration/account_test.go
- Verified in server/rpc/admin_server.go
- Verified in server/rpc/testcases/testcases.go
- Verified in api/yorkie/v1/v1connect/admin.connect.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `CreateAccount` in the codebase. # Test: Search for the method usage. Expect: Correct and consistent usage. rg --type go -A 5 $'CreateAccount'Length of output: 25657
api/converter/to_pb.go (2)
36-43
: Deprecation Notice Approved:ToUser
function.The
ToUser
function is deprecated and will be replaced byToAccount
. The notice is clear, and the function remains functional.
45-50
: Change Approved: Introduced functionToAccount
.The function converts a
*types.Account
to anapi.Account
, mirroring the implementation of the deprecatedToUser
function.Verify that the function is used correctly in the codebase.
Verification successful
Change Approved: Introduced function
ToAccount
.The function converts a
*types.Account
to anapi.Account
, mirroring the implementation of the deprecatedToUser
function. The function is used correctly in the codebase.
server/accounts/accounts.go
: Used to return the result ofToAccount()
.server/rpc/admin_server.go
: Used to assign the result to a field in a struct.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `ToAccount` in the codebase. # Test: Search for the function usage. Expect: Correct and consistent usage. rg --type go -A 5 $'ToAccount'Length of output: 2787
api/converter/from_pb.go (1)
32-37
: LGTM!The function
FromAccount
correctly maps fields from the ProtobufAccount
message to thetypes.Account
model.api/yorkie/v1/v1connect/admin.connect.go (6)
53-55
: LGTM!The
AdminServiceCreateAccountProcedure
is correctly defined and consistent with other procedure names.
58-60
: LGTM!The
AdminServiceDeleteAccountProcedure
is correctly defined and consistent with other procedure names.
61-63
: LGTM!The
AdminServiceChangeAccountPasswordProcedure
is correctly defined and consistent with other procedure names.
100-105
: LGTM!The methods
CreateAccount
,DeleteAccount
, andChangeAccountPassword
are correctly defined and consistent with other methods in theAdminServiceClient
interface.
134-153
: LGTM!The fields for
createAccount
,deleteAccount
, andchangeAccountPassword
RPC methods are correctly defined and consistent with other fields in theadminServiceClient
struct.
314-319
: LGTM!The methods
CreateAccount
,DeleteAccount
, andChangeAccountPassword
are correctly defined and consistent with other methods in theAdminServiceHandler
interface.server/backend/database/memory/database.go (8)
Line range hint
134-144
: LGTM!The function
EnsureDefaultAccountAndProject
correctly reflects the shift from user management to account management, and the return types are correctly updated.
159-180
: LGTM!The function
ensureDefaultAccountInfo
correctly reflects the shift from user management to account management, and the database table is correctly updated.
405-425
: LGTM!The function
DeleteAccountInfoByName
correctly handles the deletion of an account by name, and error handling is properly implemented.
427-449
: LGTM!The function
ChangeAccountPassword
correctly handles the password change, and error handling is properly implemented.
378-397
: LGTM!The function
CreateAccountInfo
correctly reflects the shift from user management to account management.
451-464
: LGTM!The function
FindAccountInfoByID
correctly reflects the shift from user management to account management.
467-480
: LGTM!The function
FindAccountInfoByName
correctly reflects the shift from user management to account management.
483-499
: LGTM!The function
ListAccountInfos
correctly reflects the shift from user management to account management.server/backend/database/testcases/testcases.go (7)
172-172
: LGTM!The change from
EnsureDefaultUserAndProject
toEnsureDefaultAccountAndProject
is consistent with the new terminology.
371-385
: LGTM!The changes from
RunListUserInfosTest
toRunListAccountInfosTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.
392-403
: LGTM!The changes from
RunFindUserInfoByIDTest
toRunFindAccountInfoByIDTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.
410-421
: LGTM!The changes from
RunFindUserInfoByNameTest
toRunFindAccountInfoByNameTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.
371-385
: LGTM!The changes from
RunListUserInfosTest
toRunListAccountInfosTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.
392-403
: LGTM!The changes from
RunFindUserInfoByIDTest
toRunFindAccountInfoByIDTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.
410-421
: LGTM!The changes from
RunFindUserInfoByNameTest
toRunFindAccountInfoByNameTest
and the renaming of user-related terms to account-related terms are consistent with the new terminology.api/docs/yorkie/v1/resources.openapi.yaml (2)
161-181
: LGTM!The addition of the
yorkie.v1.Account
schema with propertiescreatedAt
,id
, andusername
is well-defined and aligns with the new terminology.
1687-1687
: LGTM!The deprecation of the
yorkie.v1.User
schema is consistent with the shift to the newAccount
schema.
e06f7f9
to
acaf851
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
Outside diff range, codebase verification and nitpick comments (1)
server/backend/database/mongo/client.go (1)
Line range hint
123-155
: Renameinfo
toaccountInfo
and update error message.The variable
info
should be renamed toaccountInfo
to align with the new account-centric model. The error message should be updated to reflect the account-centric model.- info := database.AccountInfo{} - if err := result.Decode(&info); err != nil { + accountInfo := database.AccountInfo{} + if err := result.Decode(&accountInfo); err != nil { if err == mongo.ErrNoDocuments { - return nil, fmt.Errorf("default: %w", database.ErrAccountNotFound) + return nil, fmt.Errorf("default account: %w", database.ErrAccountNotFound) } - return nil, fmt.Errorf("decode user info: %w", err) + return nil, fmt.Errorf("decode account info: %w", err) } - return &info, nil + return &accountInfo, nil
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
api/yorkie/v1/resources.pb.go
is excluded by!**/*.pb.go
Files selected for processing (39)
- admin/client.go (1 hunks)
- api/converter/from_pb.go (1 hunks)
- api/converter/to_pb.go (1 hunks)
- api/docs/yorkie/v1/admin.openapi.yaml (12 hunks)
- api/docs/yorkie/v1/resources.openapi.yaml (2 hunks)
- api/types/account.go (1 hunks)
- api/types/account_fields.go (1 hunks)
- api/types/account_fields_test.go (1 hunks)
- api/yorkie/v1/admin.proto (5 hunks)
- api/yorkie/v1/resources.proto (1 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- cmd/yorkie/login.go (1 hunks)
- cmd/yorkie/server.go (2 hunks)
- design/presence.md (2 hunks)
- pkg/index/tree.go (1 hunks)
- server/accounts/accounts.go (4 hunks)
- server/accounts/context.go (1 hunks)
- server/backend/backend.go (1 hunks)
- server/backend/config.go (1 hunks)
- server/backend/database/account_info.go (1 hunks)
- server/backend/database/client_info.go (1 hunks)
- server/backend/database/database.go (3 hunks)
- server/backend/database/memory/database.go (3 hunks)
- server/backend/database/memory/database_test.go (1 hunks)
- server/backend/database/memory/indexes.go (2 hunks)
- server/backend/database/mongo/client.go (5 hunks)
- server/backend/database/mongo/client_test.go (1 hunks)
- server/backend/database/mongo/indexes.go (3 hunks)
- server/backend/database/testcases/testcases.go (2 hunks)
- server/config.go (2 hunks)
- server/rpc/admin_server.go (16 hunks)
- server/rpc/connecthelper/status.go (2 hunks)
- server/rpc/interceptors/admin.go (6 hunks)
- server/rpc/server_test.go (2 hunks)
- server/rpc/testcases/testcases.go (10 hunks)
- test/helper/helper.go (3 hunks)
- test/integration/account_test.go (1 hunks)
- test/sharding/mongo_client_test.go (1 hunks)
- test/sharding/server_test.go (2 hunks)
Files skipped from review due to trivial changes (4)
- design/presence.md
- server/backend/config.go
- server/backend/database/client_info.go
- server/config.go
Files skipped from review as they are similar to previous changes (25)
- admin/client.go
- api/docs/yorkie/v1/admin.openapi.yaml
- api/docs/yorkie/v1/resources.openapi.yaml
- api/types/account.go
- api/types/account_fields.go
- api/types/account_fields_test.go
- api/yorkie/v1/resources.proto
- api/yorkie/v1/v1connect/admin.connect.go
- cmd/yorkie/login.go
- cmd/yorkie/server.go
- pkg/index/tree.go
- server/accounts/accounts.go
- server/backend/backend.go
- server/backend/database/account_info.go
- server/backend/database/database.go
- server/backend/database/memory/database_test.go
- server/backend/database/memory/indexes.go
- server/rpc/admin_server.go
- server/rpc/connecthelper/status.go
- server/rpc/server_test.go
- server/rpc/testcases/testcases.go
- test/helper/helper.go
- test/integration/account_test.go
- test/sharding/mongo_client_test.go
- test/sharding/server_test.go
Additional comments not posted (36)
server/accounts/context.go (3)
17-17
: LGTM!The package name change from
users
toaccounts
aligns with the new account-centric model.
25-26
: LGTM!The type name change from
userKey
toaccountKey
aligns with the new account-centric model.
29-35
: LGTM!The function signature changes from handling
*types.User
to*types.Account
are consistent with the new account-centric model. The context handling appears correct.server/backend/database/mongo/client_test.go (3)
83-85
: LGTM!The test case name change from
ListUserInfos
toListAccountInfos
aligns with the new account-centric model.
88-89
: LGTM!The test case name change from
FindUserInfoByID
toFindAccountInfoByID
aligns with the new account-centric model.
92-92
: Update the test function name for consistency.The test function name should be updated to reflect the new account-centric model.
- testcases.RunFindUserInfoByNameTest(t, cli) + testcases.RunFindAccountInfoByNameTest(t, cli)Likely invalid or redundant comment.
server/backend/database/mongo/indexes.go (3)
31-32
: LGTM!The collection name change from
ColUsers
toColAccounts
aligns with the new account-centric model.
48-48
: LGTM!The update to replace
ColUsers
withColAccounts
in theCollections
variable aligns with the new account-centric model.
Line range hint
80-85
:
LGTM!The update to replace
ColUsers
withColAccounts
in thecollectionInfos
structure aligns with the new account-centric model.api/yorkie/v1/admin.proto (5)
29-31
: LGTM! Deprecation and replacement of SignUp RPC.The SignUp RPC is correctly marked as deprecated and replaced by the CreateAccount RPC.
33-34
: LGTM! Addition of DeleteAccount and ChangeAccountPassword RPCs.The new RPCs for DeleteAccount and ChangeAccountPassword are correctly defined.
60-63
: LGTM! Addition of CreateAccountRequest message.The CreateAccountRequest message is correctly defined with
username
andpassword
fields.
78-81
: LGTM! Addition of DeleteAccountRequest message.The DeleteAccountRequest message is correctly defined with
username
andpassword
fields.
86-90
: LGTM! Addition of ChangeAccountPasswordRequest message.The ChangeAccountPasswordRequest message is correctly defined with
username
,current_password
, andnew_password
fields.server/rpc/interceptors/admin.go (4)
167-167
: LGTM! Updated context management inbuildContext
.The context management is correctly updated to use
accounts
instead ofusers
.
Line range hint
179-201
:
LGTM! Updatedauthenticate
function to useaccounts
.The
authenticate
function is correctly updated to useaccounts
instead ofusers
.
201-204
: LGTM! Updatedauthenticate
function to useaccounts
for project owner.The
authenticate
function is correctly updated to useaccounts
instead ofusers
for the project owner.
45-48
: Verify the security implications of the updatedisRequiredAuth
function.The updated
isRequiredAuth
function now includes additional methods that do not require authentication. Ensure this change does not introduce security vulnerabilities.api/converter/to_pb.go (2)
36-43
: LGTM! Deprecation and update ofToUser
function.The
ToUser
function is correctly deprecated and updated to useaccount
instead ofuser
.
45-50
: LGTM! Addition ofToAccount
function.The
ToAccount
function is correctly defined to convert a*types.Account
to anapi.Account
.api/converter/from_pb.go (1)
32-37
: LGTM!The function correctly converts the Protobuf
Account
object to thetypes.Account
object. The changes reflect the shift from user-centric to account-centric data handling.server/backend/database/memory/database.go (9)
134-140
: LGTM!The function correctly ensures the creation of default account and project. The changes reflect the shift from user-centric to account-centric data handling.
159-180
: LGTM!The function correctly ensures the creation of the default account. The changes reflect the shift from user-centric to account-centric data handling.
378-397
: LGTM!The function correctly creates a new account. The changes reflect the shift from user-centric to account-centric data handling.
405-425
: LGTM!The function correctly deletes an account by name. It follows a similar transaction pattern as the previous user functions.
427-448
: LGTM!The function correctly changes the password for an account. It follows a similar transaction pattern as the previous user functions.
451-464
: LGTM!The function correctly finds an account by the given ID. The changes reflect the shift from user-centric to account-centric data handling.
467-480
: LGTM!The function correctly finds an account by the given username. The changes reflect the shift from user-centric to account-centric data handling.
483-499
: LGTM!The function correctly lists all accounts. The changes reflect the shift from user-centric to account-centric data handling.
134-140
: LGTM!The function correctly ensures the creation of default account and project. The changes reflect the shift from user-centric to account-centric data handling.
server/backend/database/mongo/client.go (2)
Line range hint
504-549
: LGTM!The function
ActivateClient
is correctly implemented and does not require any changes.
Line range hint
550-606
: LGTM!The function
DeactivateClient
is correctly implemented and does not require any changes.server/backend/database/testcases/testcases.go (4)
392-403
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
RunFindAccountInfoByIDTest
match the new signature.Verification successful
Verified: All function calls to
RunFindAccountInfoByIDTest
match the new signature.The function
RunFindAccountInfoByIDTest
is correctly used in the codebase with the updated signature.
server/backend/database/mongo/client_test.go
server/backend/database/memory/database_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `RunFindAccountInfoByIDTest` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'RunFindAccountInfoByIDTest'Length of output: 1571
172-172
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
EnsureDefaultAccountAndProject
match the new signature.Verification successful
Verification successful: Function usage matches the new signature.
The function
EnsureDefaultAccountAndProject
is consistently used with the new signature across the codebase.
server/backend/backend.go
server/backend/database/database.go
server/backend/database/memory/database.go
server/backend/database/mongo/client.go
server/backend/database/testcases/testcases.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `EnsureDefaultAccountAndProject` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'EnsureDefaultAccountAndProject'Length of output: 3580
410-421
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
RunFindAccountInfoByNameTest
match the new signature.
371-385
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
RunListAccountInfosTest
match the new signature.Verification successful
Function usage verified successfully.
All instances of
RunListAccountInfosTest
match the new function signature and are used correctly.
test/sharding/mongo_client_test.go
server/backend/database/memory/database_test.go
server/backend/database/mongo/client_test.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `RunListAccountInfosTest` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'RunListAccountInfosTest'Length of output: 1899
Script:
#!/bin/bash # Verify the function calls to `RunListAccountInfosTest` in the listed files. # Check `test/sharding/mongo_client_test.go` rg --type go -A 5 -B 5 'RunListAccountInfosTest' test/sharding/mongo_client_test.go # Check `server/backend/database/memory/database_test.go` rg --type go -A 5 -B 5 'RunListAccountInfosTest' server/backend/database/memory/database_test.go # Check `server/backend/database/mongo/client_test.go` rg --type go -A 5 -B 5 'RunListAccountInfosTest' server/backend/database/mongo/client_test.goLength of output: 1288
acaf851
to
9ab1142
Compare
renamed the signup_fields file that does the validation to user_fields to equalize the validation for the user, and I added ChangePasswordFields, with a comment saying that it should have the same validation as signup.
# Conflicts: # server/backend/database/database.go # server/backend/database/mongo/client.go
After discussing with @gusah009, we have concluded what we revert our changes to use RPC name as I apologize for the frequent change request to @gusah009. Thank you for your understanding. |
9ab1142
to
ddfdff5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
api/yorkie/v1/admin.pb.go
is excluded by!**/*.pb.go
Files selected for processing (16)
- api/docs/yorkie/v1/admin.openapi.yaml (54 hunks)
- api/docs/yorkie/v1/resources.openapi.yaml (64 hunks)
- api/docs/yorkie/v1/yorkie.openapi.yaml (49 hunks)
- api/types/user_fields.go (1 hunks)
- api/types/user_fields_test.go (1 hunks)
- api/yorkie/v1/admin.proto (2 hunks)
- api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
- server/backend/database/database.go (1 hunks)
- server/backend/database/memory/database.go (1 hunks)
- server/backend/database/mongo/client.go (1 hunks)
- server/rpc/admin_server.go (2 hunks)
- server/rpc/interceptors/admin.go (1 hunks)
- server/rpc/server_test.go (1 hunks)
- server/rpc/testcases/testcases.go (2 hunks)
- server/users/users.go (1 hunks)
- test/helper/helper.go (1 hunks)
Files skipped from review due to trivial changes (2)
- api/docs/yorkie/v1/resources.openapi.yaml
- api/docs/yorkie/v1/yorkie.openapi.yaml
Files skipped from review as they are similar to previous changes (12)
- api/docs/yorkie/v1/admin.openapi.yaml
- api/types/user_fields.go
- api/types/user_fields_test.go
- api/yorkie/v1/admin.proto
- api/yorkie/v1/v1connect/admin.connect.go
- server/backend/database/database.go
- server/backend/database/memory/database.go
- server/backend/database/mongo/client.go
- server/rpc/server_test.go
- server/rpc/testcases/testcases.go
- server/users/users.go
- test/helper/helper.go
Additional comments not posted (5)
server/rpc/interceptors/admin.go (3)
45-47
: Security Risk: Review the decision to bypass authentication for additional methods.Adding
ChangePassword
andDeleteAccount
to the list of methods that do not require authentication could pose a security risk. Ensure that this decision is intentional and consider the potential implications.
Line range hint
66-66
:
LGTM! Consistent with the shift to account-centric handling.The change from
users.With
toaccounts.With
aligns with the transition to account-centric handling.
Line range hint
79-79
:
LGTM! Consistent with the shift to account-centric handling.The changes from
users.GetUserByName
toaccounts.GetAccountByName
andusers.GetUserByID
toaccounts.GetAccountByID
align with the transition to account-centric handling.Also applies to: 85-85, 92-92
server/rpc/admin_server.go (2)
98-119
: Enhance error handling and logging.Consider adding more specific error messages and logging for better traceability.
func (s *adminServer) DeleteAccount( ctx context.Context, req *connect.Request[api.DeleteAccountRequest], ) (*connect.Response[api.DeleteAccountResponse], error) { user, err := users.IsCorrectPassword( ctx, s.backend, req.Msg.Username, req.Msg.Password, ) if err != nil { logging.DefaultLogger().Errorf("Failed to validate password for user: %s, error: %v", req.Msg.Username, err) return nil, fmt.Errorf("failed to validate password for user %s: %w", req.Msg.Username, err) } err = users.DeleteAccountByName(ctx, s.backend, user.Username) if err != nil { logging.DefaultLogger().Errorf("Failed to delete account for user: %s, error: %v", user.Username, err) return nil, fmt.Errorf("failed to delete account for user %s: %w", user.Username, err) } logging.DefaultLogger().Infof("Account deleted for user: %s", user.Username) return connect.NewResponse(&api.DeleteAccountResponse{}), nil }
121-147
: Enhance error handling and logging.Consider adding more specific error messages and logging for better traceability.
func (s *adminServer) ChangePassword( ctx context.Context, req *connect.Request[api.ChangePasswordRequest], ) (*connect.Response[api.ChangePasswordResponse], error) { fields := &types.UserFields{Username: &req.Msg.Username, Password: &req.Msg.NewPassword} if err := fields.Validate(); err != nil { logging.DefaultLogger().Errorf("Failed to validate new password for user: %s, error: %v", req.Msg.Username, err) return nil, fmt.Errorf("failed to validate new password for user %s: %w", req.Msg.Username, err) } user, err := users.IsCorrectPassword( ctx, s.backend, req.Msg.Username, req.Msg.CurrentPassword, ) if err != nil { logging.DefaultLogger().Errorf("Failed to validate current password for user: %s, error: %v", req.Msg.Username, err) return nil, fmt.Errorf("failed to validate current password for user %s: %w", req.Msg.Username, err) } err = users.ChangePassword(ctx, s.backend, user.Username, req.Msg.NewPassword) if err != nil { logging.DefaultLogger().Errorf("Failed to change password for user: %s, error: %v", user.Username, err) return nil, fmt.Errorf("failed to change password for user %s: %w", user.Username, err) } logging.DefaultLogger().Infof("Password changed for user: %s", user.Username) return connect.NewResponse(&api.ChangePasswordResponse{}), nil }
ca0dc39
to
7022723
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #934 +/- ##
==========================================
- Coverage 51.53% 51.31% -0.22%
==========================================
Files 71 71
Lines 10586 10679 +93
==========================================
+ Hits 5455 5480 +25
- Misses 4585 4650 +65
- Partials 546 549 +3 ☔ View full report in Codecov by Sentry. |
@hackerwins We did not consider cascading delete on user related objects including projects and documents. I think we need to also consider to also delete related resources. |
@krapie Please create an issue regarding this. 🙏 |
What this PR does / why we need it:
Added the admin APIs ChangePassword and DeleteAccount.
As their names suggest, these are APIs for changing passwords and deleting accounts.
Which issue(s) this PR fixes:
Fixes #849
Special notes for your reviewer:
I've verified that it works with mongoDB and in-memory DBs using postman.
As mentioned below, we will need to open an endpoint to access this API from your dashboard or CLI. client development is not included in this PR.
I generated the files with the
make proto
command, which broke the formatting of theapi/docs/yorkie/v1/*.openapi.yaml
files.I wanted the validation of
username
orpassword
onChangePassword
to be the same asSignUp
, but I didn't know how to separate them into a common string, so I added a warning as a comment. If there's a good way to do it, I'd love to hear about it :)Does this PR introduce a user-facing change?:
There is no user impact yet. we need to open an endpoint that the client can access from the dashboard or CLI.
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation