mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 07:07:32 +00:00
fix: change to repository event types and removed unused code (#3386)
* fix: change to repository event types and removed unused code * some fixes * remove unused code
This commit is contained in:
@@ -2,12 +2,12 @@ package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/caos/logging"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
"net"
|
||||
|
||||
"github.com/caos/zitadel/internal/auth_request/model"
|
||||
"github.com/caos/logging"
|
||||
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type AuthRequest struct {
|
||||
@@ -17,51 +17,12 @@ type AuthRequest struct {
|
||||
*BrowserInfo
|
||||
}
|
||||
|
||||
func AuthRequestFromModel(request *model.AuthRequest) *AuthRequest {
|
||||
req := &AuthRequest{
|
||||
ID: request.ID,
|
||||
UserAgentID: request.AgentID,
|
||||
SelectedIDPConfigID: request.SelectedIDPConfigID,
|
||||
}
|
||||
if request.BrowserInfo != nil {
|
||||
req.BrowserInfo = BrowserInfoFromModel(request.BrowserInfo)
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func AuthRequestToModel(request *AuthRequest) *model.AuthRequest {
|
||||
req := &model.AuthRequest{
|
||||
ID: request.ID,
|
||||
AgentID: request.UserAgentID,
|
||||
SelectedIDPConfigID: request.SelectedIDPConfigID,
|
||||
}
|
||||
if request.BrowserInfo != nil {
|
||||
req.BrowserInfo = BrowserInfoToModel(request.BrowserInfo)
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
type BrowserInfo struct {
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
AcceptLanguage string `json:"acceptLanguage,omitempty"`
|
||||
RemoteIP net.IP `json:"remoteIP,omitempty"`
|
||||
}
|
||||
|
||||
func BrowserInfoFromModel(info *model.BrowserInfo) *BrowserInfo {
|
||||
return &BrowserInfo{
|
||||
UserAgent: info.UserAgent,
|
||||
AcceptLanguage: info.AcceptLanguage,
|
||||
RemoteIP: info.RemoteIP,
|
||||
}
|
||||
}
|
||||
|
||||
func BrowserInfoToModel(info *BrowserInfo) *model.BrowserInfo {
|
||||
return &model.BrowserInfo{
|
||||
UserAgent: info.UserAgent,
|
||||
AcceptLanguage: info.AcceptLanguage,
|
||||
RemoteIP: info.RemoteIP,
|
||||
}
|
||||
}
|
||||
func (a *AuthRequest) SetData(event *es_models.Event) error {
|
||||
if err := json.Unmarshal(event.Data, a); err != nil {
|
||||
logging.Log("EVEN-T5df6").WithError(err).Error("could not unmarshal event data")
|
||||
|
Reference in New Issue
Block a user