♻️ Replace nil context with context.Background in authkit
This commit is contained in:
		
							
								
								
									
										22
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										22
									
								
								.idea/workspace.xml
									
									
									
										generated
									
									
									
								
							| @@ -4,13 +4,13 @@ | ||||
|     <option name="autoReloadType" value="ALL" /> | ||||
|   </component> | ||||
|   <component name="ChangeListManager"> | ||||
|     <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Realm operations now available in authkit"> | ||||
|     <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix grpc namespace conflict"> | ||||
|       <change afterPath="$PROJECT_DIR$/pkg/authkit/auth.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/authkit/audit.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/audit.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/authkit/notify.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/notify.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/internal/grpc/notify.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/notify.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/proto/notify.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/notify.pb.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/proto/notify.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/notify.proto" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/proto/notify_grpc.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/proto/notify_grpc.pb.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/authkit/realm.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/realm.go" afterDir="false" /> | ||||
|       <change beforePath="$PROJECT_DIR$/pkg/authkit/relative.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/relative.go" afterDir="false" /> | ||||
|     </list> | ||||
|     <option name="SHOW_DIALOG" value="false" /> | ||||
|     <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||||
| @@ -33,10 +33,10 @@ | ||||
|     </option> | ||||
|     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | ||||
|   </component> | ||||
|   <component name="KubernetesApiPersistence"><![CDATA[{}]]></component> | ||||
|   <component name="KubernetesApiProvider"><![CDATA[{ | ||||
|   "isMigrated": true | ||||
| }]]></component> | ||||
|   <component name="KubernetesApiPersistence">{}</component> | ||||
|   <component name="KubernetesApiProvider">{ | ||||
|   "isMigrated": true | ||||
| }</component> | ||||
|   <component name="ProblemsViewState"> | ||||
|     <option name="selectedTabId" value="ProjectErrors" /> | ||||
|   </component> | ||||
| @@ -162,7 +162,6 @@ | ||||
|   </component> | ||||
|   <component name="VcsManagerConfiguration"> | ||||
|     <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> | ||||
|     <MESSAGE value=":bug: Bug fixes on settings auth preferences" /> | ||||
|     <MESSAGE value=":sparkles: Implement event recorder grpc" /> | ||||
|     <MESSAGE value=":sparkles: More event logs point" /> | ||||
|     <MESSAGE value=":sparkles: New login alert" /> | ||||
| @@ -187,7 +186,8 @@ | ||||
|     <MESSAGE value=":technologist: Improve DX by extending authkit" /> | ||||
|     <MESSAGE value=":sparkles: Add list relative method into authkit" /> | ||||
|     <MESSAGE value=":sparkles: Realm operations now available in authkit" /> | ||||
|     <option name="LAST_COMMIT_MESSAGE" value=":sparkles: Realm operations now available in authkit" /> | ||||
|     <MESSAGE value=":bug: Fix grpc namespace conflict" /> | ||||
|     <option name="LAST_COMMIT_MESSAGE" value=":bug: Fix grpc namespace conflict" /> | ||||
|     <option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" /> | ||||
|   </component> | ||||
|   <component name="VgoProject"> | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package authkit | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex/sec" | ||||
| @@ -13,7 +14,7 @@ func AddEvent(nx *nex.Conn, userId uint, action, target, ip, ua string) error { | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("failed to get auth service client: %v", err) | ||||
| 	} | ||||
| 	_, err = proto.NewAuditServiceClient(conn).RecordEvent(nil, &proto.RecordEventRequest{ | ||||
| 	_, err = proto.NewAuditServiceClient(conn).RecordEvent(context.Background(), &proto.RecordEventRequest{ | ||||
| 		UserId:    uint64(userId), | ||||
| 		Action:    action, | ||||
| 		Target:    target, | ||||
| @@ -33,7 +34,7 @@ func AddEventExt(nx *nex.Conn, action, target string, c *fiber.Ctx) error { | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("failed to get auth service client: %v", err) | ||||
| 	} | ||||
| 	_, err = proto.NewAuditServiceClient(conn).RecordEvent(nil, &proto.RecordEventRequest{ | ||||
| 	_, err = proto.NewAuditServiceClient(conn).RecordEvent(context.Background(), &proto.RecordEventRequest{ | ||||
| 		UserId:    uint64(user.ID), | ||||
| 		Action:    action, | ||||
| 		Target:    target, | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package authkit | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex" | ||||
| 	"git.solsynth.dev/hypernet/passport/pkg/proto" | ||||
| @@ -17,7 +18,7 @@ func NotifyUser(nx *nex.Conn, userId uint64, notify pushkit.Notification, unsave | ||||
| 	if len(unsaved) == 0 { | ||||
| 		unsaved = append(unsaved, false) | ||||
| 	} | ||||
| 	_, err = proto.NewNotifyServiceClient(conn).NotifyUser(nil, &proto.NotifyUserRequest{ | ||||
| 	_, err = proto.NewNotifyServiceClient(conn).NotifyUser(context.Background(), &proto.NotifyUserRequest{ | ||||
| 		UserId: userId, | ||||
| 		Notify: &proto.NotifyInfoPayload{ | ||||
| 			Unsaved: unsaved[0], | ||||
| @@ -36,7 +37,7 @@ func NotifyUserBatch(nx *nex.Conn, userId []uint64, notify pushkit.Notification, | ||||
| 	if len(unsaved) == 0 { | ||||
| 		unsaved = append(unsaved, false) | ||||
| 	} | ||||
| 	_, err = proto.NewNotifyServiceClient(conn).NotifyUserBatch(nil, &proto.NotifyUserBatchRequest{ | ||||
| 	_, err = proto.NewNotifyServiceClient(conn).NotifyUserBatch(context.Background(), &proto.NotifyUserBatchRequest{ | ||||
| 		UserId: userId, | ||||
| 		Notify: &proto.NotifyInfoPayload{ | ||||
| 			Unsaved: unsaved[0], | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package authkit | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex" | ||||
| 	"git.solsynth.dev/hypernet/passport/pkg/authkit/models" | ||||
| 	"git.solsynth.dev/hypernet/passport/pkg/proto" | ||||
| @@ -13,7 +14,7 @@ func GetRealm(nx *nex.Conn, id uint) (models.Realm, error) { | ||||
| 	if err != nil { | ||||
| 		return realm, err | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealm(context.Background(), &proto.LookupRealmRequest{ | ||||
| 		Id: lo.ToPtr(uint64(id)), | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| @@ -28,7 +29,7 @@ func GetRealmByAlias(nx *nex.Conn, alias string) (models.Realm, error) { | ||||
| 	if err != nil { | ||||
| 		return realm, err | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealm(context.Background(), &proto.LookupRealmRequest{ | ||||
| 		Alias: &alias, | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| @@ -43,7 +44,7 @@ func ListRealm(nx *nex.Conn, id []uint) ([]models.Realm, error) { | ||||
| 	if err != nil { | ||||
| 		return realms, err | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).ListRealm(nil, &proto.ListRealmRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).ListRealm(context.Background(), &proto.ListRealmRequest{ | ||||
| 		Id: lo.Map(id, func(item uint, _ int) uint64 { | ||||
| 			return uint64(item) | ||||
| 		}), | ||||
| @@ -63,7 +64,7 @@ func GetRealmMember(nx *nex.Conn, realmID, userID uint) (models.RealmMember, err | ||||
| 	if err != nil { | ||||
| 		return member, err | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealmMember(nil, &proto.RealmMemberLookupRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ | ||||
| 		RealmId: lo.ToPtr(uint64(realmID)), | ||||
| 		UserId:  lo.ToPtr(uint64(userID)), | ||||
| 	}) | ||||
| @@ -79,7 +80,7 @@ func ListRealmMember(nx *nex.Conn, realmID uint) ([]models.RealmMember, error) { | ||||
| 	if err != nil { | ||||
| 		return members, err | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).ListRealmMember(nil, &proto.RealmMemberLookupRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).ListRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ | ||||
| 		RealmId: lo.ToPtr(uint64(realmID)), | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| @@ -96,7 +97,7 @@ func CheckRealmMemberPerm(nx *nex.Conn, realmID uint, userID, power int) bool { | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).CheckRealmMemberPerm(nil, &proto.CheckRealmPermRequest{ | ||||
| 	resp, err := proto.NewRealmServiceClient(conn).CheckRealmMemberPerm(context.Background(), &proto.CheckRealmPermRequest{ | ||||
| 		RealmId:    uint64(realmID), | ||||
| 		UserId:     uint64(userID), | ||||
| 		PowerLevel: int32(power), | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package authkit | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/proto" | ||||
| ) | ||||
| @@ -10,10 +11,13 @@ func ListRelative(nx *nex.Conn, userId uint, status int32, isRelated bool) ([]*p | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	resp, err := proto.NewUserServiceClient(conn).ListUserRelative(nil, &proto.ListUserRelativeRequest{ | ||||
| 	resp, err := proto.NewUserServiceClient(conn).ListUserRelative(context.Background(), &proto.ListUserRelativeRequest{ | ||||
| 		UserId:    uint64(userId), | ||||
| 		Status:    status, | ||||
| 		IsRelated: isRelated, | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return resp.GetData(), err | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user