3
0

Improve rval for /check endpoint (now uses outgoing.User)

This commit is contained in:
Denis Arh 2018-10-14 09:44:11 +02:00
parent 602f77c2f1
commit 64aee5a25b
3 changed files with 8 additions and 4 deletions

View File

@ -6,8 +6,10 @@ import (
"net/http"
"github.com/crusttech/crust/auth/repository"
"github.com/crusttech/crust/auth/types"
"github.com/crusttech/crust/internal/auth"
"github.com/crusttech/crust/internal/payload"
"github.com/crusttech/crust/internal/payload/outgoing"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
@ -17,8 +19,8 @@ import (
type (
checkResponse struct {
JWT string `json:"jwt"`
User *types.User `json:"user"`
JWT string `json:"jwt"`
User *outgoing.User `json:"user"`
}
)
@ -48,7 +50,7 @@ func MountRoutes(oidcConfig *config.OIDC, jwtAuth jwtEncodeCookieSetter) func(ch
if user, err := service.DefaultUser.With(ctx).FindByID(identity.Identity()); err == nil {
resputil.JSON(w, checkResponse{
JWT: c.Value,
User: user,
User: payload.User(user),
})
return

View File

@ -105,6 +105,7 @@ func User(user *auth.User) *outgoing.User {
Name: user.Name,
Handle: user.Handle,
Username: user.Username,
Email: user.Email,
}
}

View File

@ -9,6 +9,7 @@ type (
// Channel to part (nil) for ALL channels
ID string `json:"ID"`
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
Handle string `json:"handle"`
Connections uint `json:"connections"`