|
|
|
@@ -60,7 +60,7 @@ func setupHTTPHandler() { |
|
|
|
http.HandleFunc("/crmfiles/", crmAttachmentHandler) |
|
|
|
http.HandleFunc("/dumprequest", dumpReuestHandler) |
|
|
|
http.HandleFunc("/MP_verify_6JqVkftKr39GMakA.txt", mpDomainAuthSecret) |
|
|
|
http.HandleFunc("/profile_newly_register", initialRegistrationHandler) |
|
|
|
http.HandleFunc("/redirect", setTrackingCookieAndRecirect) |
|
|
|
http.HandleFunc("/iapi/getAccessToken", supplyAccessToken) |
|
|
|
http.HandleFunc("/iapi/createWechatQr", iapiCreateWechatQrCode) |
|
|
|
http.HandleFunc("/crmpixel.png", crmpixel) //tracking pixel. |
|
|
|
@@ -189,14 +189,19 @@ func mpDomainAuthSecret(w http.ResponseWriter, r *http.Request) { |
|
|
|
//or if the user has already been registered, |
|
|
|
//redirect user to a URL "/pages/dashboard" |
|
|
|
// |
|
|
|
func initialRegistrationHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
//TODO: verify url parameters and make sure its username is correctly set |
|
|
|
// |
|
|
|
expiration := time.Now().Add(10 * 365 * 24 * time.Hour) |
|
|
|
str := time.Now().String() |
|
|
|
cookie := http.Cookie{Name: "username", Value: str, Expires: expiration} |
|
|
|
http.SetCookie(w, &cookie) |
|
|
|
cookie = http.Cookie{Name: "signature", Value: "abcee", Expires: expiration} |
|
|
|
func setTrackingCookieAndRecirect(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
cookie := crmpixelCookie(r) |
|
|
|
http.SetCookie(w, &cookie) |
|
|
|
http.Redirect(w, r, "http://192.168.1.39:4200/#pages/charts/chartist-js", 307) //302 temp redirect |
|
|
|
|
|
|
|
rq := r.URL.RawQuery |
|
|
|
m, _ := url.ParseQuery(rq) |
|
|
|
|
|
|
|
url, ok := m["url"] |
|
|
|
if ok { |
|
|
|
http.Redirect(w, r, url[0], 307) //302 temp redirect |
|
|
|
return |
|
|
|
} |
|
|
|
w.WriteHeader(http.StatusNotFound) |
|
|
|
fmt.Fprintf(w, "Not Found URL") |
|
|
|
} |