mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
step
This commit is contained in:
parent
bb0af8ac11
commit
415452dd89
1 changed files with 22 additions and 1 deletions
|
@ -109,11 +109,32 @@ func (ctrl *V1Controller) HandleSsoHeaderLogin() errchain.HandlerFunc {
|
|||
return validate.NewRequestError(errors.New("authentication failed. not SSO header found or empty"), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
usr, err := ctrl.repo.Users.GetOneEmail(r.Context(), email)
|
||||
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
newToken, err := ctrl.svc.User.LoginWithoutPassword(r.Context(), strings.ToLower(email), false)
|
||||
|
||||
if err != nil {
|
||||
var username = r.Header.Get("Remote-Name")
|
||||
|
||||
regData := services.UserRegistration {
|
||||
GroupToken: "adf",
|
||||
Name : username,
|
||||
Email : email,
|
||||
Password : "",
|
||||
}
|
||||
|
||||
_, err := ctrl.svc.User.RegisterUser(r.Context(), regData)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to register user from SSO HTTP headers")
|
||||
return validate.NewRequestError(err, http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
|
||||
return server.JSON(w, http.StatusOK, TokenResponse{
|
||||
Token: "Bearer " + newToken.Raw,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue