Bunch of work around assigning reports to districts
I added some DB schema to track logos and to relate reports to organizations. I reworked how GPS data comes from EXIF data on images because it wasn't working for JPEGs. I might have broken PNGs in the process. Also made the config options for domain names more standardized.
This commit is contained in:
parent
486a2d98c2
commit
61d8d14fc2
41 changed files with 3029 additions and 337 deletions
|
|
@ -284,7 +284,7 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
|
|||
}
|
||||
data := ContextDashboard{
|
||||
Config: Config{
|
||||
URLTegola: config.URLTegola,
|
||||
URLTegola: config.MakeURLTegola("/"),
|
||||
},
|
||||
CountTraps: int(trapCount),
|
||||
CountMosquitoSources: int(sourceCount),
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func getQRCodeReport(w http.ResponseWriter, r *http.Request) {
|
|||
if code == "" {
|
||||
respondError(w, "There should always be a code", nil, http.StatusBadRequest)
|
||||
}
|
||||
content := config.MakeURLSync("/report/" + code)
|
||||
content := config.MakeURLNidus("/report/%s", code)
|
||||
// Get optional size parameter (default to 256)
|
||||
size := 256
|
||||
if sizeStr := r.URL.Query().Get("size"); sizeStr != "" {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package sync
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/auth"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/background"
|
||||
|
|
@ -19,8 +21,33 @@ type ContextOauthPrompt struct {
|
|||
User User
|
||||
}
|
||||
|
||||
// Build the ArcGIS authorization URL with PKCE
|
||||
func buildArcGISAuthURL(clientID string) string {
|
||||
baseURL := "https://www.arcgis.com/sharing/rest/oauth2/authorize/"
|
||||
|
||||
params := url.Values{}
|
||||
params.Add("client_id", clientID)
|
||||
params.Add("redirect_uri", config.ArcGISOauthRedirectURL())
|
||||
params.Add("response_type", "code")
|
||||
//params.Add("code_challenge", generateCodeChallenge(codeVerifier))
|
||||
//params.Add("code_challenge_method", "S256")
|
||||
|
||||
// See https://developers.arcgis.com/rest/users-groups-and-items/token/
|
||||
// expiration is defined in minutes
|
||||
var expiration int
|
||||
if config.IsProductionEnvironment() {
|
||||
// 2 weeks is the maximum allowed
|
||||
expiration = 20160
|
||||
} else {
|
||||
expiration = 20
|
||||
}
|
||||
params.Add("expiration", strconv.Itoa(expiration))
|
||||
|
||||
return baseURL + "?" + params.Encode()
|
||||
}
|
||||
|
||||
func getArcgisOauthBegin(w http.ResponseWriter, r *http.Request) {
|
||||
authURL := config.BuildArcGISAuthURL(config.ClientID)
|
||||
authURL := buildArcGISAuthURL(config.ClientID)
|
||||
http.Redirect(w, r, authURL, http.StatusFound)
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +68,7 @@ func getArcgisOauthCallback(w http.ResponseWriter, r *http.Request) {
|
|||
respondError(w, "Failed to handle access code", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, config.MakeURLSync("/"), http.StatusFound)
|
||||
http.Redirect(w, r, config.MakeURLNidus("/"), http.StatusFound)
|
||||
}
|
||||
|
||||
func getOAuthRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue