(ctx context.Context, args *proto.CheckAuthRequest, reply *proto.CheckAuthResponse)
| 112 | } |
| 113 | |
| 114 | func (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 | |
| 136 | func (rpc *RpcLogic) Logout(ctx context.Context, args *proto.LogoutRequest, reply *proto.LogoutResponse) (err error) { |
| 137 | reply.Code = config.FailReplyCode |
nothing calls this directly
no test coverage detected