Currently we have some license issues. We are working on it.

Commit e24668ec authored by zauberstuhl's avatar zauberstuhl
Browse files

Drop nginx rewrite config

parent 1878789f
FROM golang:1.12
FROM golang:1.10
RUN go get -u github.com/golang/dep/cmd/dep
......
......@@ -78,11 +78,6 @@ func auth_handler(w http.ResponseWriter, r *http.Request) {
}
defer db.Close()
userParam := viper.GetString("nginxRewrite")
if userParam == "" {
userParam = "/users/?user=%s"
}
if codes, ok := r.URL.Query()["code"]; ok {
token, err := fetch_auth(codes[0])
if err != nil {
......@@ -99,6 +94,7 @@ func auth_handler(w http.ResponseWriter, r *http.Request) {
return
}
userParam := "/users/%s"
err = db.First(&User{}, "username = ?", username).Error
if err == nil {
http.Redirect(w, r,
......
#nginxRewrite: "/users/%s"
redirectUrl: http://localhost:8080
# untappd app secret
......
......@@ -23,6 +23,7 @@ import (
"net/http"
"html/template"
"io/ioutil"
"regexp"
"log"
"github.com/spf13/viper"
......@@ -43,13 +44,6 @@ var TemplateFuncs = map[string]interface{}{
p := bluemonday.StrictPolicy()
return template.HTML(p.Sanitize(text))
},
"rwNginx": func(username string) string {
nginxRewrite := viper.GetString("nginxRewrite")
if nginxRewrite == "" {
nginxRewrite = "/users/?user=%s"
}
return fmt.Sprintf(nginxRewrite, username)
},
"lenLoc": func(loc Locations) int {
return len(loc)
},
......@@ -64,9 +58,10 @@ func user_handler(w http.ResponseWriter, r *http.Request) {
defer db.Close()
var user User
paramUser, userOK := r.URL.Query()["user"]
if userOK {
err = db.First(&user, "username = ?", paramUser[0]).Error
pattern := regexp.MustCompile(`([^/]+)$`)
matches := pattern.FindAllString(r.URL.String(), 1)
if len(matches) > 0 {
err = db.First(&user, "username = ?", matches[0]).Error
if err == nil {
// first time setup
if viper.GetBool("worker") && len(user.Locations) == 0 {
......@@ -98,11 +93,7 @@ func index_handler(w http.ResponseWriter, r *http.Request) {
paramUser, userOK := r.URL.Query()["user"]
if userOK {
rwParam := viper.GetString("nginxRewrite")
if rwParam == "" {
rwParam = "/users/?user=%s"
}
http.Redirect(w, r, fmt.Sprintf(rwParam, paramUser[0]), 301)
http.Redirect(w, r, fmt.Sprintf("/users/%s", paramUser[0]), 301)
return
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment