Skip to content
Snippets Groups Projects
Commit 69973a0c authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Define the token tmpl as a string

parent f1a898a1
Branches
Tags
No related merge requests found
......@@ -13,7 +13,6 @@ import (
"log"
"net/http"
"os"
"path"
"strings"
"time"
......@@ -27,6 +26,7 @@ import (
"github.com/nsheridan/cashier/server/auth/google"
"github.com/nsheridan/cashier/server/config"
"github.com/nsheridan/cashier/server/signer"
"github.com/nsheridan/cashier/templates"
)
var (
......@@ -38,7 +38,6 @@ type appContext struct {
cookiestore *sessions.CookieStore
authprovider auth.Provider
authsession *auth.Session
views *template.Template
sshKeySigner *signer.KeySigner
}
......@@ -154,7 +153,9 @@ func rootHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, er
page := struct {
Token string
}{tok.AccessToken}
a.views.ExecuteTemplate(w, "token.html", page)
tmpl := template.Must(template.New("token.html").Parse(templates.Token))
tmpl.Execute(w, page)
return http.StatusOK, nil
}
......@@ -226,7 +227,6 @@ func main() {
ctx := &appContext{
cookiestore: sessions.NewCookieStore([]byte(config.Server.CookieSecret)),
authprovider: authprovider,
views: template.Must(template.ParseGlob(path.Join(config.Server.TemplateDir, "*"))),
sshKeySigner: signer,
}
ctx.cookiestore.Options = &sessions.Options{
......
......@@ -4,8 +4,7 @@
"tls_key": "server.key",
"tls_cert": "server.crt",
"port": 443,
"cookie_secret": "supersecret",
"template_dir": "/go/src/github.com/nsheridan/cashier/templates"
"cookie_secret": "supersecret"
},
"auth": {
"provider": "google",
......
<html>
package templates
const Token = `<html>
<head>
<title>YOUR TOKEN!</title>
<style>
......@@ -43,4 +45,4 @@
The token will expire in &lt; 1 hour.
</h2>
</body>
</html>
</html>`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment