Skip to content
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

Invite New Member error #692

Closed
leipeizhao opened this issue Sep 27, 2024 · 4 comments
Closed

Invite New Member error #692

leipeizhao opened this issue Sep 27, 2024 · 4 comments
Assignees
Labels
bug Something isn't working v0.9.0

Comments

@leipeizhao
Copy link

Describe the bug
invite new member to a organization error

Environment
CSGHub Version: v0.9
OS: Linux
Launch: docker compose

To Reproduce
Steps to reproduce the behavior:

  1. Go to a organization detail
  2. Click on 'invite'
  3. input username,go 404 page
  4. See error https://192.168.73.2/api/v1/users?search=a 404
@zhendi
Copy link
Collaborator

zhendi commented Oct 15, 2024

hi, I can not reproduced this bug, could you please provide some logs and/or screenshots? thanks.

@leipeizhao
Copy link
Author

search user url :/api/v1/users?search=xx

 async function getUsers(username) {
    const usersEndpoint = `/users?search=${username}`
    const options = {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json'
      }
    }

server router does not have get request

{
		apiGroup.POST("/users", userProxyHandler.ProxyToApi("/api/v1/user"))
		apiGroup.PUT("/users/:username", userProxyHandler.ProxyToApi("/api/v1/user/%v", "username"))
	}

@leipeizhao
Copy link
Author

no pictures,i fixed it

apiV1Group.GET("/users", userHandler.SearchByName)

func (h *UserHandler) SearchByName(ctx *gin.Context) {
	userName := ctx.Query("search")
	user, err := h.c.SearchByName(ctx, userName)
	if err != nil {
		slog.Error("Failed to get user", slog.Any("error", err))
		httpbase.ServerError(ctx, err)
		return
	}

	slog.Info("Search user succeed", slog.String("userName", userName))
	httpbase.OK(ctx, user)
}



func (s *UserStore) FindUsersByName(ctx context.Context, username string) (users []User, err error) {
	err = s.db.Operator.Core.NewSelect().Model(&users).Where("username like ?", fmt.Sprintf("%s%%", username)).Scan(ctx)
	return
}

@Rader
Copy link
Collaborator

Rader commented Oct 16, 2024

@leipeizhao would you mind of creating a PR for this bug fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.9.0
Projects
None yet
Development

No branches or pull requests

3 participants