예제 #1
0
파일: users.go 프로젝트: henrydo/ags
func verifyRecover(req *restful.Request, resp *restful.Response) {
	magic := req.PathParameter("recover_magic")
	log.Debug("magic is %s", magic)
	ret, id := dbVerifyRecover(magic)
	if ret == http.StatusOK {
		auth.AddCookie(req.Request, resp.ResponseWriter, strconv.FormatInt(id, 10))
		http.Redirect(resp.ResponseWriter, req.Request, "/#!/mypassword", http.StatusFound)

	} else {
		resp.WriteErrorString(ret, http.StatusText(ret))
	}
}
예제 #2
0
파일: users.go 프로젝트: henrydo/ags
func signinUser(request *restful.Request, response *restful.Response) {
	usr := new(User)
	err := request.ReadEntity(&usr)
	if err == nil {
		if ret := dbCheckUser(usr); ret == http.StatusOK {
			auth.AddCookie(request.Request, response.ResponseWriter, usr.Id)
			response.WriteEntity(usr)
		} else {
			response.WriteErrorString(ret, http.StatusText(ret))
		}
	} else {
		response.WriteError(http.StatusInternalServerError, err)
	}
}