Remove oauth refresh from dash, remove QR code (its in platform)

This commit is contained in:
Eli Ribble 2026-02-28 23:18:25 +00:00
parent 558412cfb4
commit 29bd1fab5c
No known key found for this signature in database
6 changed files with 16 additions and 96 deletions

View file

@ -32,7 +32,7 @@ type contentSettingOrganization struct {
} }
type contentSettingIntegration struct { type contentSettingIntegration struct {
ArcGISOAuth *models.OauthToken ArcGISOAuth *models.ArcgisOauthToken
} }
func getConfigurationOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingOrganization], *errorWithStatus) { func getConfigurationOrganization(ctx context.Context, r *http.Request, org *models.Organization, u *models.User) (*response[contentSettingOrganization], *errorWithStatus) {

View file

@ -83,23 +83,13 @@ func getRoot(w http.ResponseWriter, r *http.Request) {
signin(w, errorCode, "/") signin(w, errorCode, "/")
return return
} else { } else {
has, err := background.HasFieldseekerConnection(ctx, user) org, err := user.Organization().One(ctx, db.PGInstance.BobDB)
if err != nil { if err != nil {
respondError(w, "Failed to check for ArcGIS connection", err, http.StatusInternalServerError) respondError(w, "Failed to get organization", err, http.StatusInternalServerError)
return
}
if has {
org, err := user.Organization().One(ctx, db.PGInstance.BobDB)
if err != nil {
respondError(w, "Failed to get organization", err, http.StatusInternalServerError)
return
}
dashboard(ctx, w, org, user)
return
} else {
oauthPrompt(w, r, user)
return return
} }
dashboard(ctx, w, org, user)
return
} }
} }

View file

@ -2,14 +2,10 @@ package sync
import ( import (
"fmt" "fmt"
"net/http"
"strconv"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/html" "github.com/Gleipnir-Technology/nidus-sync/html"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"net/http"
//"github.com/rs/zerolog/log" //"github.com/rs/zerolog/log"
"github.com/skip2/go-qrcode"
) )
// Unauthenticated pages // Unauthenticated pages
@ -42,66 +38,6 @@ import (
settingUsersAdd = buildTemplate("setting-user-add", "base") settingUsersAdd = buildTemplate("setting-user-add", "base")
*/ */
func getQRCodeReport(w http.ResponseWriter, r *http.Request) {
code := chi.URLParam(r, "code")
if code == "" {
respondError(w, "There should always be a code", nil, http.StatusBadRequest)
}
content := config.MakeURLNidus("/report/%s", code)
// Get optional size parameter (default to 256)
size := 256
if sizeStr := r.URL.Query().Get("size"); sizeStr != "" {
var err error
size, err = strconv.Atoi(sizeStr)
if err != nil {
http.Error(w, "Invalid 'size' parameter, must be an integer", http.StatusBadRequest)
return
}
}
// Get optional error correction level (default to Medium)
level := qrcode.Medium
if levelStr := r.URL.Query().Get("level"); levelStr != "" {
switch levelStr {
case "L", "l":
level = qrcode.Low
case "M", "m":
level = qrcode.Medium
case "Q", "q":
level = qrcode.High
case "H", "h":
level = qrcode.Highest
default:
respondError(w, "Invalid 'level' parameter, must be L, M, Q, or H", nil, http.StatusBadRequest)
return
}
}
// Generate the QR code
var qr *qrcode.QRCode
var err error
qr, err = qrcode.New(content, level)
if err != nil {
respondError(w, "Error generating QR code", err, http.StatusInternalServerError)
return
}
// Set the appropriate content type
w.Header().Set("Content-Type", "image/png")
// Generate PNG and write directly to the response writer
png, err := qr.PNG(size)
if err != nil {
respondError(w, "Error encoding QR code to PNG", err, http.StatusInternalServerError)
return
}
_, err = w.Write(png)
if err != nil {
respondError(w, "Error writing response", err, http.StatusInternalServerError)
}
}
type mock struct { type mock struct {
Path string Path string
template string template string

View file

@ -1,6 +1,7 @@
package sync package sync
import ( import (
"context"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@ -9,11 +10,10 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/background" "github.com/Gleipnir-Technology/nidus-sync/background"
"github.com/Gleipnir-Technology/nidus-sync/config" "github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/html"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
type ContextOauthPrompt struct{} type contentOauthPrompt struct{}
// Build the ArcGIS authorization URL with PKCE // Build the ArcGIS authorization URL with PKCE
func buildArcGISAuthURL(clientID string) string { func buildArcGISAuthURL(clientID string) string {
@ -65,16 +65,7 @@ func getArcgisOauthCallback(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, config.MakeURLNidus("/"), http.StatusFound) http.Redirect(w, r, config.MakeURLNidus("/"), http.StatusFound)
} }
func getOAuthRefresh(w http.ResponseWriter, r *http.Request) { func getOAuthRefresh(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentOauthPrompt], *errorWithStatus) {
user, err := auth.GetAuthenticatedUser(r) data := contentOauthPrompt{}
if err != nil { return newResponse("sync/oauth-prompt.html", data), nil
http.Redirect(w, r, "/?next=/oauth/refresh", http.StatusFound)
return
}
oauthPrompt(w, r, user)
}
func oauthPrompt(w http.ResponseWriter, r *http.Request, user *models.User) {
data := ContextOauthPrompt{}
html.RenderOrError(w, "sync/oauth-prompt.html", data)
} }

View file

@ -22,6 +22,8 @@ func Router() chi.Router {
// Unauthenticated endpoints // Unauthenticated endpoints
r.Get("/arcgis/oauth/begin", getArcgisOauthBegin) r.Get("/arcgis/oauth/begin", getArcgisOauthBegin)
r.Get("/arcgis/oauth/callback", getArcgisOauthCallback) r.Get("/arcgis/oauth/callback", getArcgisOauthCallback)
r.Get("/mailer/{code}", getMailer)
r.Get("/mailer/{code}/preview", getMailerPreview)
r.Get("/district", getDistrict) r.Get("/district", getDistrict)
// Mock endpoints // Mock endpoints
@ -35,9 +37,9 @@ func Router() chi.Router {
addMock(r, "/mock/report/{code}/update", "sync/mock/report-update.html") addMock(r, "/mock/report/{code}/update", "sync/mock/report-update.html")
// Utility endpoints // Utility endpoints
r.Get("/oauth/refresh", getOAuthRefresh)
r.Get("/privacy", getPrivacy) r.Get("/privacy", getPrivacy)
r.Get("/qr-code/report/{code}", getQRCodeReport) r.Get("/qr-code/report/{code}", getQRCodeReport)
r.Get("/qr-code/mailer/{code}", getQRCodeMailer)
r.Get("/signin", getSignin) r.Get("/signin", getSignin)
r.Post("/signin", postSignin) r.Post("/signin", postSignin)
r.Get("/signup", getSignup) r.Get("/signup", getSignup)
@ -60,7 +62,9 @@ func Router() chi.Router {
r.Method("GET", "/layout-test", authenticatedHandler(getLayoutTest)) r.Method("GET", "/layout-test", authenticatedHandler(getLayoutTest))
r.Method("GET", "/message", authenticatedHandler(getMessageList)) r.Method("GET", "/message", authenticatedHandler(getMessageList))
r.Method("GET", "/notification", authenticatedHandler(getNotificationList)) r.Method("GET", "/notification", authenticatedHandler(getNotificationList))
r.Method("GET", "/oauth/refresh", authenticatedHandler(getOAuthRefresh))
r.Method("GET", "/operations", authenticatedHandler(getOperationsRoot)) r.Method("GET", "/operations", authenticatedHandler(getOperationsRoot))
r.Method("GET", "/parcel", authenticatedHandler(getParcel))
r.Method("GET", "/planning", authenticatedHandler(getPlanningRoot)) r.Method("GET", "/planning", authenticatedHandler(getPlanningRoot))
r.Method("GET", "/pool", authenticatedHandler(getPoolList)) r.Method("GET", "/pool", authenticatedHandler(getPoolList))
r.Method("GET", "/pool/create", authenticatedHandler(getPoolCreate)) r.Method("GET", "/pool/create", authenticatedHandler(getPoolCreate))

View file

@ -11,7 +11,6 @@ type contentURL struct {
Route string Route string
SamplePoolCSV string SamplePoolCSV string
Sidebar contentURLSidebar Sidebar contentURLSidebar
Setting contentURLSetting
Tegola string Tegola string
UploadCSVPool string UploadCSVPool string
} }