Added optional Discourse SSO.
This commit is contained in:
parent
5527c1eb91
commit
54da04763f
8 changed files with 337 additions and 8 deletions
|
|
@ -27,6 +27,14 @@ func (app *App) handleGetSettings(w http.ResponseWriter, r *http.Request) {
|
|||
noteLabel = "Additional note"
|
||||
}
|
||||
|
||||
var ssoURL, ssoSecret string
|
||||
app.db.QueryRow(`SELECT value FROM config WHERE key = 'discourse_sso_url'`).Scan(&ssoURL)
|
||||
app.db.QueryRow(`SELECT value FROM config WHERE key = 'discourse_sso_secret'`).Scan(&ssoSecret)
|
||||
maskedSSOSecret := ""
|
||||
if ssoSecret != "" {
|
||||
maskedSSOSecret = "***"
|
||||
}
|
||||
|
||||
writeJSON(w, map[string]any{
|
||||
"smtp_host": cfg.Host,
|
||||
"smtp_port": cfg.Port,
|
||||
|
|
@ -38,6 +46,8 @@ func (app *App) handleGetSettings(w http.ResponseWriter, r *http.Request) {
|
|||
"volunteer_note_label": noteLabel,
|
||||
"volunteer_note_required": noteRequired == "true",
|
||||
"shift_signups_open": signupsOpen == "true",
|
||||
"discourse_sso_url": ssoURL,
|
||||
"discourse_sso_secret": maskedSSOSecret,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +59,7 @@ func (app *App) handleUpdateSettings(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
keys := []string{"smtp_host", "smtp_port", "smtp_user", "smtp_password", "smtp_from", "smtp_from_name", "base_url",
|
||||
"volunteer_note_label", "volunteer_note_required"}
|
||||
"volunteer_note_label", "volunteer_note_required", "discourse_sso_url", "discourse_sso_secret"}
|
||||
for _, k := range keys {
|
||||
v, ok := body[k]
|
||||
if !ok {
|
||||
|
|
@ -58,7 +68,7 @@ func (app *App) handleUpdateSettings(w http.ResponseWriter, r *http.Request) {
|
|||
var val string
|
||||
switch vv := v.(type) {
|
||||
case string:
|
||||
if k == "smtp_password" && (vv == "" || vv == "***") {
|
||||
if (k == "smtp_password" || k == "discourse_sso_secret") && (vv == "" || vv == "***") {
|
||||
continue
|
||||
}
|
||||
val = vv
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue