MCPcopy Create free account
hub / github.com/LockGit/gochat / CheckAuth

Method CheckAuth

logic/rpc.go:114–134  ·  view source on GitHub ↗
(ctx context.Context, args *proto.CheckAuthRequest, reply *proto.CheckAuthResponse)

Source from the content-addressed store, hash-verified

112}
113
114func (rpc *RpcLogic) CheckAuth(ctx context.Context, args *proto.CheckAuthRequest, reply *proto.CheckAuthResponse) (err error) {
115 reply.Code = config.FailReplyCode
116 authToken := args.AuthToken
117 sessionName := tools.GetSessionName(authToken)
118 var userDataMap = map[string]string{}
119 userDataMap, err = RedisSessClient.HGetAll(sessionName).Result()
120 if err != nil {
121 logrus.Infof("check auth fail!,authToken is:%s", authToken)
122 return err
123 }
124 if len(userDataMap) == 0 {
125 logrus.Infof("no this user session,authToken is:%s", authToken)
126 return
127 }
128 intUserId, _ := strconv.Atoi(userDataMap["userId"])
129 reply.UserId = intUserId
130 userName, _ := userDataMap["userName"]
131 reply.Code = config.SuccessReplyCode
132 reply.UserName = userName
133 return
134}
135
136func (rpc *RpcLogic) Logout(ctx context.Context, args *proto.LogoutRequest, reply *proto.LogoutResponse) (err error) {
137 reply.Code = config.FailReplyCode

Callers

nothing calls this directly

Calls 1

GetSessionNameFunction · 0.92

Tested by

no test coverage detected