diff --git a/internal/actions/object/auth_request.go b/internal/actions/object/auth_request.go index 01a6f98f32..7d4d869af1 100644 --- a/internal/actions/object/auth_request.go +++ b/internal/actions/object/auth_request.go @@ -25,15 +25,11 @@ func AuthRequestFromDomain(c *actions.FieldConfig, request *domain.AuthRequest) } return c.Runtime.ToValue(&authRequest{ - Id: request.ID, - AgentId: request.AgentID, - CreationDate: request.CreationDate, - ChangeDate: request.ChangeDate, - BrowserInfo: &browserInfo{ - UserAgent: request.BrowserInfo.UserAgent, - AcceptLanguage: request.BrowserInfo.AcceptLanguage, - RemoteIp: request.BrowserInfo.RemoteIP, - }, + Id: request.ID, + AgentId: request.AgentID, + CreationDate: request.CreationDate, + ChangeDate: request.ChangeDate, + BrowserInfo: browserInfoFromDomain(request.BrowserInfo), ApplicationId: request.ApplicationID, CallbackUri: request.CallbackURI, TransferState: request.TransferState, @@ -103,6 +99,17 @@ type authRequest struct { AuthTime time.Time } +func browserInfoFromDomain(info *domain.BrowserInfo) *browserInfo { + if info == nil { + return nil + } + return &browserInfo{ + UserAgent: info.UserAgent, + AcceptLanguage: info.AcceptLanguage, + RemoteIp: info.RemoteIP, + } +} + func requestFromDomain(req domain.Request) *request { r := new(request) diff --git a/internal/api/ui/login/custom_action.go b/internal/api/ui/login/custom_action.go index c82588e183..316520fbb8 100644 --- a/internal/api/ui/login/custom_action.go +++ b/internal/api/ui/login/custom_action.go @@ -314,7 +314,7 @@ func (l *Login) runPostCreationActions( actions.SetFields("v1", actions.SetFields("getUser", func(c *actions.FieldConfig) interface{} { return func(call goja.FunctionCall) goja.Value { - user, err := l.query.GetUserByID(actionCtx, true, authRequest.UserID, false) + user, err := l.query.GetUserByID(actionCtx, true, userID, false) if err != nil { panic(err) } diff --git a/internal/api/ui/login/external_register_handler.go b/internal/api/ui/login/external_register_handler.go index 0656e777c4..713d41b607 100644 --- a/internal/api/ui/login/external_register_handler.go +++ b/internal/api/ui/login/external_register_handler.go @@ -166,7 +166,7 @@ func (l *Login) registerExternalUser(w http.ResponseWriter, r *http.Request, aut l.renderRegisterOption(w, r, authReq, err) return } - err = l.authRepo.AutoRegisterExternalUser(setContext(r.Context(), resourceOwner), user, externalIDP, nil, authReq.ID, authReq.AgentID, resourceOwner, metadata, nil) + err = l.authRepo.AutoRegisterExternalUser(setContext(r.Context(), resourceOwner), user, externalIDP, nil, authReq.ID, authReq.AgentID, resourceOwner, metadata, domain.BrowserInfoFromRequest(r)) if err != nil { l.renderRegisterOption(w, r, authReq, err) return