forked from ungerik/go-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
49 lines (40 loc) · 1.16 KB
/
config.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
package user
import (
"fmt"
"github.com/ungerik/go-start/mongo"
)
var Config = Configuration{
ConfirmationMessage: ConfirmationMessage{
EmailSubject: "Please confirm your email address for %s",
EmailMessage: "Please confirm your email address for %s by opening the following link:\n\n%s",
Sent: "We sent you an email with a verification link.<br/>It might some time to show up, but when it does you will be ready to use this site.",
},
}
func Init(collection *mongo.Collection) {
Config.Collection = collection
Config.CollectionName = collection.Name
}
type ConfirmationMessage struct {
EmailSubject string
EmailMessage string
Sent string
}
type Configuration struct {
ConfirmationMessage ConfirmationMessage
CollectionName string
Collection *mongo.Collection
}
func (self *Configuration) Name() string {
return "user"
}
func (self *Configuration) Init() error {
collection, found := mongo.CollectionByName(self.CollectionName)
if !found {
return fmt.Errorf("Can't find mongo collection with name '%s'", self.CollectionName)
}
self.Collection = collection
return nil
}
func (self *Configuration) Close() error {
return nil
}