mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-08 18:47:52 +00:00
fix management user view and user session handler (#124)
This commit is contained in:
parent
effc2c23c2
commit
f14d4cc655
@ -41,23 +41,7 @@ func (u *UserSession) EventQuery() (*models.SearchQuery, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserSession) Process(event *models.Event) (err error) {
|
func (u *UserSession) Process(event *models.Event) (err error) {
|
||||||
eventData, err := view_model.UserSessionFromEvent(event)
|
var session *view_model.UserSessionView
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
session, err := u.view.UserSessionByIDs(eventData.UserAgentID, event.AggregateID)
|
|
||||||
if err != nil {
|
|
||||||
if !errors.IsNotFound(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
session = &view_model.UserSessionView{
|
|
||||||
CreationDate: event.CreationDate,
|
|
||||||
ResourceOwner: event.ResourceOwner,
|
|
||||||
UserAgentID: eventData.UserAgentID,
|
|
||||||
UserID: event.AggregateID,
|
|
||||||
State: int32(req_model.UserSessionStateActive),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case es_model.UserPasswordCheckSucceeded,
|
case es_model.UserPasswordCheckSucceeded,
|
||||||
es_model.UserPasswordCheckFailed,
|
es_model.UserPasswordCheckFailed,
|
||||||
@ -65,6 +49,23 @@ func (u *UserSession) Process(event *models.Event) (err error) {
|
|||||||
es_model.MfaOtpCheckSucceeded,
|
es_model.MfaOtpCheckSucceeded,
|
||||||
es_model.MfaOtpCheckFailed,
|
es_model.MfaOtpCheckFailed,
|
||||||
es_model.MfaOtpRemoved:
|
es_model.MfaOtpRemoved:
|
||||||
|
eventData, err := view_model.UserSessionFromEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
session, err = u.view.UserSessionByIDs(eventData.UserAgentID, event.AggregateID)
|
||||||
|
if err != nil {
|
||||||
|
if !errors.IsNotFound(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
session = &view_model.UserSessionView{
|
||||||
|
CreationDate: event.CreationDate,
|
||||||
|
ResourceOwner: event.ResourceOwner,
|
||||||
|
UserAgentID: eventData.UserAgentID,
|
||||||
|
UserID: event.AggregateID,
|
||||||
|
State: int32(req_model.UserSessionStateActive),
|
||||||
|
}
|
||||||
|
}
|
||||||
session.AppendEvent(event)
|
session.AppendEvent(event)
|
||||||
default:
|
default:
|
||||||
return u.view.ProcessedUserSessionSequence(event.Sequence)
|
return u.view.ProcessedUserSessionSequence(event.Sequence)
|
||||||
|
9
migrations/cockroach/V1.6__management_user_view.sql
Normal file
9
migrations/cockroach/V1.6__management_user_view.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE management.users
|
||||||
|
ADD COLUMN password_set BOOLEAN,
|
||||||
|
ADD COLUMN password_change_required BOOLEAN,
|
||||||
|
ADD COLUMN mfa_max_set_up SMALLINT,
|
||||||
|
ADD COLUMN mfa_init_skipped TIMESTAMPTZ;
|
||||||
|
|
||||||
|
COMMIT;
|
Loading…
x
Reference in New Issue
Block a user