-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathusage_test.go
More file actions
34 lines (26 loc) · 945 Bytes
/
usage_test.go
File metadata and controls
34 lines (26 loc) · 945 Bytes
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
package auth_test
import (
"log"
"net/http"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
"github.com/smhanov/auth"
)
const gmailUser = "support@awesomepeaches.com"
const gmailPassword = "awernmx32hdkssk2mssxx" // app password from google
func Example() {
// configure how to send password reset emails
settings := auth.DefaultSettings
settings.SMTPServer = "smtp.gmail.com:587"
settings.SMTPUser = gmailUser
settings.SMTPPassword = gmailPassword
settings.ForgotPasswordSubject = "Password reset from awesomepeaches.com"
settings.ForgotPasswordBody = "Please go to this url to reset your password:\n\n https://awesomepeaches.com/forgot-password/?token=${TOKEN}"
settings.EmailFrom = "support@awesomepeaches.com"
db, err := sqlx.Open("sqlite3", "mydatabase.db")
if err != nil {
log.Panic(err)
}
http.Handle("/user/", auth.New(auth.NewUserDB(db), settings))
log.Fatal(http.ListenAndServe(":8080", nil))
}