CGI-FR / CGI-FR/SIGO

[FEAT][API] Add an endpoint to retrieve the current user

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
api octopize
Dominant language
Go
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Description
This endpoint allows a user to retrieve their own user information.

## Request

### Method
GET

### URL
/users/me

### Request Parameters
| Parameter | Description | Required | Example |
|---|---|---|---|
| timeout | The amount of time, in seconds, to wait for the request to complete. | No | 30 |

## Result

### Result parameters
| Parameter | Description | Type |
|---|---|---|
| id | The unique identifier for the user. | UUID |
| organization_id | The unique identifier for the organization the user belongs to. | UUID |
| username | The username of the user. | string |
| email | The email address of the user. | string |
| role | The role of the user. | UserRole |
| max_allowed_dimensions_per_dataset | The maximum number of dimensions allowed per dataset for the user. | int |
| max_allowed_lines_per_dataset | The maximum number of lines allowed per dataset for the user. | int |

### Result Body
The result body is a JSON object with the following structure:

```json
{
"id": "d810b289-53a3-48d9-a5e0-a16a64185635",
"organization_id": "30e13e75-574c-42c1-8c13-c374c372c320",
"username": "john.smith",
"email": "john.smith@example.com",
"role": "user",
"max_allowed_dimensions_per_dataset": 1000,
"max_allowed_lines_per_dataset": 1000000
}
```

## Example Curl Request

### Request
```
curl -X GET http://localhost:8080/users/me
```

### Curl Response
```
HTTP/1.1 200 OK
Content-Type: application/json

{
"id": "d810b289-53a3-48d9-a5e0-a16a64185635",
"organization_id": "30e13e75-574c-42c1-8c13-c374c372c320",
"username": "john.smith",
"email": "john.smith@example.com",
"role": "user",
"max_allowed_dimensions_per_dataset": 1000,
"max_allowed_lines_per_dataset": 1000000
}
```

## Go server

### Struct
```go
type User struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Username string `json:"username"`
Email string `json:"email"`
Role UserRole `json:"role"`
MaxAllowedDimensionsPerDataset int `json:"max_allowed_dimensions_per_dataset"`
MaxAllowedLinesPerDataset int `json:"max_allowed_lines_per_dataset"`
}
```

### Handler
```go
func (s *server) handleGetMe(ctx context.Context, w http.ResponseWriter, r *http.Request) {

ctx, cancel := context.WithTimeout(ctx, s.timeout)
defer cancel()

user, err := s.service.GetMe(ctx)
if err != nil {
log.Printf("failed to get user: %v", err)
http.Error(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
return
}

if err := json.NewEncoder(w).Encode(user); err != nil {
log.Printf("failed to encode user: %v", err)
http.Error(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
return
}
}
``` to the response.
w.Write(json)
}
```
## Links

- [Users.get_me](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L1170)
- [User](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L1170)

## Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project [avatar-python](https://github.com/octopize/avatar-python/) to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.

Best regards,
The SIGO Team

Contributor guide

Open the contributing guide

Research direction

Start by locating the Go server's user routes, service methods, and the handleGetMe handler and User struct shown in the issue; no repository file or test is named. Compare nearby authenticated user endpoints and the linked Users.get_me reference, then verify that GET /users/me returns the documented JSON response and handles failures consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.