forked from zitadel/zitadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
policy_login.go
106 lines (94 loc) · 2.64 KB
/
policy_login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package instance
import (
"context"
"time"
"github.com/dennigogo/zitadel/internal/eventstore"
"github.com/dennigogo/zitadel/internal/domain"
"github.com/dennigogo/zitadel/internal/eventstore/repository"
"github.com/dennigogo/zitadel/internal/repository/policy"
)
var (
LoginPolicyAddedEventType = instanceEventTypePrefix + policy.LoginPolicyAddedEventType
LoginPolicyChangedEventType = instanceEventTypePrefix + policy.LoginPolicyChangedEventType
)
type LoginPolicyAddedEvent struct {
policy.LoginPolicyAddedEvent
}
func NewLoginPolicyAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
allowUsernamePassword,
allowRegister,
allowExternalIDP,
forceMFA,
hidePasswordReset,
ignoreUnknownUsernames,
allowDomainDiscovery,
disableLoginWithEmail,
disableLoginWithPhone bool,
passwordlessType domain.PasswordlessType,
defaultRedirectURI string,
passwordCheckLifetime,
externalLoginCheckLifetime,
mfaInitSkipLifetime,
secondFactorCheckLifetime,
multiFactorCheckLifetime time.Duration,
) *LoginPolicyAddedEvent {
return &LoginPolicyAddedEvent{
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
LoginPolicyAddedEventType),
allowUsernamePassword,
allowRegister,
allowExternalIDP,
forceMFA,
hidePasswordReset,
ignoreUnknownUsernames,
allowDomainDiscovery,
disableLoginWithEmail,
disableLoginWithPhone,
passwordlessType,
defaultRedirectURI,
passwordCheckLifetime,
externalLoginCheckLifetime,
mfaInitSkipLifetime,
secondFactorCheckLifetime,
multiFactorCheckLifetime),
}
}
func LoginPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := policy.LoginPolicyAddedEventMapper(event)
if err != nil {
return nil, err
}
return &LoginPolicyAddedEvent{LoginPolicyAddedEvent: *e.(*policy.LoginPolicyAddedEvent)}, nil
}
type LoginPolicyChangedEvent struct {
policy.LoginPolicyChangedEvent
}
func NewLoginPolicyChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
changes []policy.LoginPolicyChanges,
) (*LoginPolicyChangedEvent, error) {
changedEvent, err := policy.NewLoginPolicyChangedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
LoginPolicyChangedEventType),
changes,
)
if err != nil {
return nil, err
}
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *changedEvent}, nil
}
func LoginPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := policy.LoginPolicyChangedEventMapper(event)
if err != nil {
return nil, err
}
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *e.(*policy.LoginPolicyChangedEvent)}, nil
}