Exemplo n.º 1
0
Arquivo: users.go Projeto: 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))
	}
}
Exemplo n.º 2
0
Arquivo: users.go Projeto: 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)
	}
}