7 // User represents a mailmux user.
9 // The name should be a valid email address.
16 // A UserStore provides storage and authentication of users.
17 type UserStore interface {
18 // Change creates or updates the named user with the new password.
19 Change(name string, new Password) error
20 // Lookup returns the User with name.
21 // The error should be ErrUnknownUser if the user is not found.
22 Lookup(name string) (User, error)
23 // Delete removes the user from the store.
24 Delete(name string) error
25 // Authenticate authenticates the user identified by username with pw.
26 // error is non-nil if the password is incorrect or on any other error.
27 Authenticate(username string, pw Password) error
32 var testTicket = []byte(`TEST NOT REAL`)
35 ErrUserExist = errors.New("user already exists")
36 ErrUnknownUser = errors.New("unknown user")
39 // verified checks whether ownership of username's address has
41 // func (store *astore) verified(username string) (bool, error) {
42 // _, err := store.Lookup(username)
43 // if errors.Is(err, ErrUnknownUser) {
47 // _, err = os.Stat(path.Join(store.confirmDir, username))
51 // if errors.Is(err, fs.ErrNotExist) {
54 // return false, fmt.Errorf("check confirm file: %w", err)
57 // verify attempts to verify the username using the given token.
58 // func (store *astore) verify(username string, tok token) error {
59 // f, err := os.Open(path.Join(store.confirmDir, username))
60 // if errors.Is(err, fs.ErrNotExist) {
61 // return ErrUnknownUser
62 // } else if err != nil {
66 // b, err := io.ReadAll(f)
70 // if bytes.Equal(b, []byte(tok)) {
71 // return os.Remove(path.Join(store.confirmDir, username))
73 // return errors.New("mismatched token")
76 func SendConfirmationMail(from, to string, tik ticket) error {
80 // Subject: Confirm address ownership
82 // Thanks for signing up to mailmux.net!
83 // Confirm ownership of $address by accessing the following link:
84 // https://mailmux.net/confirm?username=test@example.com&token=abcd12345
85 // Alternatively, go to https://mailmux.net/confirm
86 // enter your email address and your token:
89 // If you have not signed up for mailmux.net, please
90 // let us know by forwarding this mail to abuse@mailmux.net.
91 // Thank you for helping us fight spam!