-
Notifications
You must be signed in to change notification settings - Fork 2
/
organisation.go
71 lines (63 loc) · 2.15 KB
/
organisation.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
package actor
import (
"fmt"
"time"
)
const memberInviteExpireAfter = time.Hour * 48
// An Organisation contains users associated with a set of permissions that work on the
// same set of LPAs.
type Organisation struct {
PK, SK string
// CreatedAt is when the Organisation was created
CreatedAt time.Time
// UpdatedAt is when the Organisation was last updated
UpdatedAt time.Time
// ID is a unique identifier for the Organisation
ID string
// Name of the Organisation, this is unique across all Organisations
Name string
}
// A Member is the association of a OneLogin user with an Organisation.
type Member struct {
PK, SK string
// CreatedAt is when the Member was created
CreatedAt time.Time
// UpdatedAt is when the Member was last updated
UpdatedAt time.Time
// LastLoggedInAt is when the Member last logged in to the service
LastLoggedInAt time.Time
Email string
FirstNames string
LastName string
// Permission is the type of permissions assigned to the member to set available actions in an Organisation
Permission Permission
}
func (i Member) FullName() string {
return fmt.Sprintf("%s %s", i.FirstNames, i.LastName)
}
// A MemberInvite is created to allow a new Member to join an Organisation
type MemberInvite struct {
PK, SK string
// CreatedAt is when the MemberInvite was created
CreatedAt time.Time
// UpdatedAt is when the MemberInvite was last updated
UpdatedAt time.Time
// OrganisationID identifies the organisation the invite is for
OrganisationID string
// OrganisationName is the name of the organisation the invite is for
OrganisationName string
// Email is the address the new Member must sign in as for the invite
Email string
FirstNames string
LastName string
// Permission is the type of permissions assigned to the member to set available actions in an Organisation
Permission Permission
// ReferenceNumber is a unique code used to invite a Member to and Organisation
ReferenceNumber string
}
func (i MemberInvite) HasExpired() bool {
return i.CreatedAt.Add(memberInviteExpireAfter).Before(time.Now())
}
func (i MemberInvite) FullName() string {
return fmt.Sprintf("%s %s", i.FirstNames, i.LastName)
}