feat: profile picture

This commit is contained in:
2025-05-24 17:45:47 +02:00
parent 1840194bae
commit 47f5188961

View File

@ -44,13 +44,14 @@ func (h *AuthHandler) getProfile(w http.ResponseWriter, r *http.Request) {
} }
if err := json.NewEncoder(w).Encode(map[string]any{ if err := json.NewEncoder(w).Encode(map[string]any{
"full_name": user.FullName, "full_name": user.FullName,
"email": user.Email, "email": user.Email,
"phoneNumber": user.PhoneNumber, "phoneNumber": user.PhoneNumber,
"isAdmin": user.IsAdmin, "isAdmin": user.IsAdmin,
"last_login": user.LastLogin, "last_login": user.LastLogin,
"updated_at": user.UpdatedAt, "profile_picture": user.ProfilePicture.String,
"created_at": user.CreatedAt, "updated_at": user.UpdatedAt,
"created_at": user.CreatedAt,
}); err != nil { }); err != nil {
web.Error(w, "failed to encode user profile", http.StatusInternalServerError) web.Error(w, "failed to encode user profile", http.StatusInternalServerError)
} }
@ -124,18 +125,20 @@ func (h *AuthHandler) login(w http.ResponseWriter, r *http.Request) {
AccessToken string `json:"access"` AccessToken string `json:"access"`
RefreshToken string `json:"refresh"` RefreshToken string `json:"refresh"`
// fields required for UI in account selector, e.g. email, full name and avatar // fields required for UI in account selector, e.g. email, full name and avatar
FullName string `json:"full_name"` FullName string `json:"full_name"`
Email string `json:"email"` Email string `json:"email"`
Id string `json:"id"` Id string `json:"id"`
ProfilePicture string `json:"profile_picture"`
// Avatar // Avatar
} }
if err := encoder.Encode(Response{ if err := encoder.Encode(Response{
AccessToken: accessToken, AccessToken: accessToken,
RefreshToken: refreshToken, RefreshToken: refreshToken,
FullName: user.FullName, FullName: user.FullName,
Email: user.Email, Email: user.Email,
Id: user.ID.String(), Id: user.ID.String(),
ProfilePicture: user.ProfilePicture.String,
// Avatar // Avatar
}); err != nil { }); err != nil {
web.Error(w, "failed to encode response", http.StatusInternalServerError) web.Error(w, "failed to encode response", http.StatusInternalServerError)