fix management user view and user session handler (#124)

This commit is contained in:
Livio Amstutz 2020-05-19 07:07:58 +02:00 committed by GitHub
parent effc2c23c2
commit f14d4cc655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 17 deletions

View File

@ -41,11 +41,19 @@ func (u *UserSession) EventQuery() (*models.SearchQuery, error) {
}
func (u *UserSession) Process(event *models.Event) (err error) {
var session *view_model.UserSessionView
switch event.Type {
case es_model.UserPasswordCheckSucceeded,
es_model.UserPasswordCheckFailed,
es_model.UserPasswordChanged,
es_model.MfaOtpCheckSucceeded,
es_model.MfaOtpCheckFailed,
es_model.MfaOtpRemoved:
eventData, err := view_model.UserSessionFromEvent(event)
if err != nil {
return err
}
session, err := u.view.UserSessionByIDs(eventData.UserAgentID, event.AggregateID)
session, err = u.view.UserSessionByIDs(eventData.UserAgentID, event.AggregateID)
if err != nil {
if !errors.IsNotFound(err) {
return err
@ -58,13 +66,6 @@ func (u *UserSession) Process(event *models.Event) (err error) {
State: int32(req_model.UserSessionStateActive),
}
}
switch event.Type {
case es_model.UserPasswordCheckSucceeded,
es_model.UserPasswordCheckFailed,
es_model.UserPasswordChanged,
es_model.MfaOtpCheckSucceeded,
es_model.MfaOtpCheckFailed,
es_model.MfaOtpRemoved:
session.AppendEvent(event)
default:
return u.view.ProcessedUserSessionSequence(event.Sequence)

View 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;