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,23 +41,7 @@ func (u *UserSession) EventQuery() (*models.SearchQuery, error) {
}
func (u *UserSession) Process(event *models.Event) (err error) {
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),
}
}
var session *view_model.UserSessionView
switch event.Type {
case es_model.UserPasswordCheckSucceeded,
es_model.UserPasswordCheckFailed,
@ -65,6 +49,23 @@ func (u *UserSession) Process(event *models.Event) (err error) {
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)
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)
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;