user.go

 1package proto
 2
 3import "golang.org/x/crypto/ssh"
 4
 5// User is an interface representing a user.
 6type User interface {
 7	// ID returns the user's ID.
 8	ID() int64
 9	// Username returns the user's username.
10	Username() string
11	// IsAdmin returns whether the user is an admin.
12	IsAdmin() bool
13	// PublicKeys returns the user's public keys.
14	PublicKeys() []ssh.PublicKey
15	// Password returns the user's password hash.
16	Password() string
17	// Emails returns the user's emails.
18	Emails() []UserEmail
19}
20
21// UserOptions are options for creating a user.
22type UserOptions struct {
23	// Admin is whether the user is an admin.
24	Admin bool
25	// PublicKeys are the user's public keys.
26	PublicKeys []ssh.PublicKey
27	// Emails are the user's emails.
28	// The first email in the slice will be set as the user's primary email.
29	Emails []string
30}
31
32// UserEmail represents a user's email address.
33type UserEmail interface {
34	// ID returns the email's ID.
35	ID() int64
36
37	// Email returns the email address.
38	Email() string
39
40	// IsPrimary returns whether the email is the user's primary email.
41	IsPrimary() bool
42}