-
Notifications
You must be signed in to change notification settings - Fork 2
/
organisation.go
83 lines (74 loc) · 2.61 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
72
73
74
75
76
77
78
79
80
81
82
83
package actor
import (
"fmt"
"time"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
)
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 dynamo.OrganisationKeyType
// CreatedAt is when the Organisation was created
CreatedAt time.Time
// UpdatedAt is when the Organisation was last updated
UpdatedAt time.Time
// DeletedAt is when the Organisation was (soft) deleted
DeletedAt 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 dynamo.OrganisationKeyType
SK dynamo.MemberKeyType
// CreatedAt is when the Member was created
CreatedAt time.Time
// UpdatedAt is when the Member was last updated
UpdatedAt time.Time
// ID is a unique identifier for the Member
ID string
// OrganisationID identifies the organisation the member belongs to
OrganisationID string
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
// Status controls access to the Organisation
Status Status
// LastLoggedInAt is when the Member last logged in to the service
LastLoggedInAt time.Time
}
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 dynamo.OrganisationKeyType
SK dynamo.MemberInviteKeyType
// 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)
}