Remove oauth refresh from dash, remove QR code (its in platform)
This commit is contained in:
parent
558412cfb4
commit
29bd1fab5c
6 changed files with 16 additions and 96 deletions
|
|
@ -32,7 +32,7 @@ type contentSettingOrganization 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) {
|
||||
|
|
|
|||
18
sync/dash.go
18
sync/dash.go
|
|
@ -83,23 +83,13 @@ func getRoot(w http.ResponseWriter, r *http.Request) {
|
|||
signin(w, errorCode, "/")
|
||||
return
|
||||
} else {
|
||||
has, err := background.HasFieldseekerConnection(ctx, user)
|
||||
org, err := user.Organization().One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to check for ArcGIS connection", 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)
|
||||
respondError(w, "Failed to get organization", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
dashboard(ctx, w, org, user)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
66
sync/mock.go
66
sync/mock.go
|
|
@ -2,14 +2,10 @@ package sync
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"net/http"
|
||||
//"github.com/rs/zerolog/log"
|
||||
"github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
// Unauthenticated pages
|
||||
|
|
@ -42,66 +38,6 @@ import (
|
|||
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 {
|
||||
Path string
|
||||
template string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
|
@ -9,11 +10,10 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/background"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type ContextOauthPrompt struct{}
|
||||
type contentOauthPrompt struct{}
|
||||
|
||||
// Build the ArcGIS authorization URL with PKCE
|
||||
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)
|
||||
}
|
||||
|
||||
func getOAuthRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := auth.GetAuthenticatedUser(r)
|
||||
if err != 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)
|
||||
func getOAuthRefresh(ctx context.Context, r *http.Request, org *models.Organization, user *models.User) (*response[contentOauthPrompt], *errorWithStatus) {
|
||||
data := contentOauthPrompt{}
|
||||
return newResponse("sync/oauth-prompt.html", data), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ func Router() chi.Router {
|
|||
// Unauthenticated endpoints
|
||||
r.Get("/arcgis/oauth/begin", getArcgisOauthBegin)
|
||||
r.Get("/arcgis/oauth/callback", getArcgisOauthCallback)
|
||||
r.Get("/mailer/{code}", getMailer)
|
||||
r.Get("/mailer/{code}/preview", getMailerPreview)
|
||||
r.Get("/district", getDistrict)
|
||||
|
||||
// Mock endpoints
|
||||
|
|
@ -35,9 +37,9 @@ func Router() chi.Router {
|
|||
addMock(r, "/mock/report/{code}/update", "sync/mock/report-update.html")
|
||||
|
||||
// Utility endpoints
|
||||
r.Get("/oauth/refresh", getOAuthRefresh)
|
||||
r.Get("/privacy", getPrivacy)
|
||||
r.Get("/qr-code/report/{code}", getQRCodeReport)
|
||||
r.Get("/qr-code/mailer/{code}", getQRCodeMailer)
|
||||
r.Get("/signin", getSignin)
|
||||
r.Post("/signin", postSignin)
|
||||
r.Get("/signup", getSignup)
|
||||
|
|
@ -60,7 +62,9 @@ func Router() chi.Router {
|
|||
r.Method("GET", "/layout-test", authenticatedHandler(getLayoutTest))
|
||||
r.Method("GET", "/message", authenticatedHandler(getMessageList))
|
||||
r.Method("GET", "/notification", authenticatedHandler(getNotificationList))
|
||||
r.Method("GET", "/oauth/refresh", authenticatedHandler(getOAuthRefresh))
|
||||
r.Method("GET", "/operations", authenticatedHandler(getOperationsRoot))
|
||||
r.Method("GET", "/parcel", authenticatedHandler(getParcel))
|
||||
r.Method("GET", "/planning", authenticatedHandler(getPlanningRoot))
|
||||
r.Method("GET", "/pool", authenticatedHandler(getPoolList))
|
||||
r.Method("GET", "/pool/create", authenticatedHandler(getPoolCreate))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ type contentURL struct {
|
|||
Route string
|
||||
SamplePoolCSV string
|
||||
Sidebar contentURLSidebar
|
||||
Setting contentURLSetting
|
||||
Tegola string
|
||||
UploadCSVPool string
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue