| "fmt" | "fmt" | ||||
| "math/rand" | "math/rand" | ||||
| "net/http" | "net/http" | ||||
| "net/url" | |||||
| "strconv" | "strconv" | ||||
| "strings" | "strings" | ||||
| "time" | "time" | ||||
| } | } | ||||
| return | 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") | |||||
| } |
| fmt.Fprintf(w, "6JqVkftKr39GMakA") | fmt.Fprintf(w, "6JqVkftKr39GMakA") | ||||
| //由于需要什么ICP备案,这个功能不能使用 | //由于需要什么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") | |||||
| } |