mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Log in user automatically after successful setup (#993)
* Log in user automatically after successful setup * Handle login failure by omitting token from response
This commit is contained in:
parent
f28bd803c4
commit
41517aa7d9
1 changed files with 10 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ type setupResponse struct {
|
|||
Admin *kolide.User `json:"admin,omitempty"`
|
||||
OrgInfo *kolide.OrgInfo `json:"org_info,omitempty"`
|
||||
KolideServerURL *string `json:"kolide_server_url"`
|
||||
Token *string `json:"token,omitempty"`
|
||||
Err error `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +38,6 @@ func makeSetupEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|||
return setupResponse{Err: err}, nil
|
||||
}
|
||||
}
|
||||
|
||||
if req.OrgInfo != nil {
|
||||
configPayload.OrgInfo = req.OrgInfo
|
||||
}
|
||||
|
|
@ -48,6 +48,14 @@ func makeSetupEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|||
if err != nil {
|
||||
return setupResponse{Err: err}, nil
|
||||
}
|
||||
// If everything works to this point, log the user in and return token. If
|
||||
// the login fails for some reason, ignore the error and don't return
|
||||
// a token, forcing the user to log in manually
|
||||
token := new(string)
|
||||
_, *token, err = svc.Login(ctx, *req.Admin.Username, *req.Admin.Password)
|
||||
if err != nil {
|
||||
token = nil
|
||||
}
|
||||
return setupResponse{
|
||||
Admin: admin,
|
||||
OrgInfo: &kolide.OrgInfo{
|
||||
|
|
@ -55,6 +63,7 @@ func makeSetupEndpoint(svc kolide.Service) endpoint.Endpoint {
|
|||
OrgLogoURL: &config.OrgLogoURL,
|
||||
},
|
||||
KolideServerURL: &config.KolideServerURL,
|
||||
Token: token,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue