summaryrefslogtreecommitdiff
path: root/internal/handlers/handler_state.go
blob: 83ed7532799e918446add80f42821c8621aa4a55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package handlers

import (
	"github.com/authelia/authelia/internal/middlewares"
)

// StateGet is the handler serving the user state.
func StateGet(ctx *middlewares.AutheliaCtx) {
	userSession := ctx.GetSession()
	stateResponse := StateResponse{
		Username:              userSession.Username,
		AuthenticationLevel:   userSession.AuthenticationLevel,
		DefaultRedirectionURL: ctx.Configuration.DefaultRedirectionURL,
	}

	err := ctx.SetJSONBody(stateResponse)
	if err != nil {
		ctx.Logger.Errorf("Unable to set state response in body: %s", err)
	}
}