mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-23 11:28:23 +00:00
fix(actions): provide browser info and handle nil pointer (#5277)
* fix(actions): provide browser info and handle nil pointer * fix(actions): use correct user id in post registration --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
This commit is contained in:
parent
737d14e81b
commit
82ffd6dffb
@ -29,11 +29,7 @@ func AuthRequestFromDomain(c *actions.FieldConfig, request *domain.AuthRequest)
|
|||||||
AgentId: request.AgentID,
|
AgentId: request.AgentID,
|
||||||
CreationDate: request.CreationDate,
|
CreationDate: request.CreationDate,
|
||||||
ChangeDate: request.ChangeDate,
|
ChangeDate: request.ChangeDate,
|
||||||
BrowserInfo: &browserInfo{
|
BrowserInfo: browserInfoFromDomain(request.BrowserInfo),
|
||||||
UserAgent: request.BrowserInfo.UserAgent,
|
|
||||||
AcceptLanguage: request.BrowserInfo.AcceptLanguage,
|
|
||||||
RemoteIp: request.BrowserInfo.RemoteIP,
|
|
||||||
},
|
|
||||||
ApplicationId: request.ApplicationID,
|
ApplicationId: request.ApplicationID,
|
||||||
CallbackUri: request.CallbackURI,
|
CallbackUri: request.CallbackURI,
|
||||||
TransferState: request.TransferState,
|
TransferState: request.TransferState,
|
||||||
@ -103,6 +99,17 @@ type authRequest struct {
|
|||||||
AuthTime time.Time
|
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 {
|
func requestFromDomain(req domain.Request) *request {
|
||||||
r := new(request)
|
r := new(request)
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ func (l *Login) runPostCreationActions(
|
|||||||
actions.SetFields("v1",
|
actions.SetFields("v1",
|
||||||
actions.SetFields("getUser", func(c *actions.FieldConfig) interface{} {
|
actions.SetFields("getUser", func(c *actions.FieldConfig) interface{} {
|
||||||
return func(call goja.FunctionCall) goja.Value {
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func (l *Login) registerExternalUser(w http.ResponseWriter, r *http.Request, aut
|
|||||||
l.renderRegisterOption(w, r, authReq, err)
|
l.renderRegisterOption(w, r, authReq, err)
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
l.renderRegisterOption(w, r, authReq, err)
|
l.renderRegisterOption(w, r, authReq, err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user