mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-04 09:23:21 +08:00
Validates that user is a human.
Add google recaptcha as an initial page before creating any session. To configure recaptcha there are 2 environment variables that are needed `GOOGLE_RECAPTCHA_SITE_KEY` and `GOOGLE_RECAPTCHA_SITE_SECRET`. The code contains development defaults that should be set in production to real values. **NOTICE: Development defaults assume that the domain is `localhost`**
This commit is contained in:
21
templates/welcome.go
Normal file
21
templates/welcome.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package templates
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
|
||||
"github.com/franela/play-with-docker/services"
|
||||
)
|
||||
|
||||
func GetWelcomeTemplate() ([]byte, error) {
|
||||
welcomeTemplate, tplErr := template.New("welcome").ParseFiles("www/welcome.html")
|
||||
if tplErr != nil {
|
||||
return nil, tplErr
|
||||
}
|
||||
var b bytes.Buffer
|
||||
tplExecuteErr := welcomeTemplate.ExecuteTemplate(&b, "GOOGLE_RECAPTCHA_SITE_KEY", services.GetGoogleRecaptchaSiteKey())
|
||||
if tplExecuteErr != nil {
|
||||
return nil, tplExecuteErr
|
||||
}
|
||||
return b.Bytes(), nil
|
||||
}
|
Reference in New Issue
Block a user