| @@ -7,6 +7,7 @@ import ( | |||
| "fmt" | |||
| "math/rand" | |||
| "net/http" | |||
| "net/url" | |||
| "strconv" | |||
| "strings" | |||
| "time" | |||
| @@ -140,3 +141,32 @@ func crmpixelLead(id string) (info crmdLead, err error) { | |||
| } | |||
| return | |||
| } | |||
| //for user's initial registration, especially for wechat users | |||
| //they visit a url that is specifically designed for them to | |||
| //auth and input their profile data. | |||
| //the url's query string will contains a token and a signature | |||
| //so that it's verified, by single get request, to allow people to | |||
| //enter their details into the CRM system. | |||
| // | |||
| //this handler, check's the query sting ,set an auth cookie to the client | |||
| //and serve angular app, through an URL "/profile/edit" | |||
| //or if the user has already been registered, | |||
| //redirect user to a URL "/pages/dashboard" | |||
| // | |||
| func setTrackingCookieAndRecirect(w http.ResponseWriter, r *http.Request) { | |||
| cookie := crmpixelCookie(r) | |||
| http.SetCookie(w, &cookie) | |||
| 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") | |||
| } | |||
| @@ -176,32 +176,3 @@ func mpDomainAuthSecret(w http.ResponseWriter, r *http.Request) { | |||
| fmt.Fprintf(w, "6JqVkftKr39GMakA") | |||
| //由于需要什么ICP备案,这个功能不能使用 | |||
| } | |||
| //for user's initial registration, especially for wechat users | |||
| //they visit a url that is specifically designed for them to | |||
| //auth and input their profile data. | |||
| //the url's query string will contains a token and a signature | |||
| //so that it's verified, by single get request, to allow people to | |||
| //enter their details into the CRM system. | |||
| // | |||
| //this handler, check's the query sting ,set an auth cookie to the client | |||
| //and serve angular app, through an URL "/profile/edit" | |||
| //or if the user has already been registered, | |||
| //redirect user to a URL "/pages/dashboard" | |||
| // | |||
| func setTrackingCookieAndRecirect(w http.ResponseWriter, r *http.Request) { | |||
| cookie := crmpixelCookie(r) | |||
| http.SetCookie(w, &cookie) | |||
| 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") | |||
| } | |||