|
|
@ -1038,11 +1038,24 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err |
|
|
|
|
|
|
|
|
|
|
|
flashes, _ := getSessionFlashes(app, w, r, nil) |
|
|
|
flashes, _ := getSessionFlashes(app, w, r, nil) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enableOauthSlack := app.Config().SlackOauth.ClientID != "" |
|
|
|
|
|
|
|
enableOauthWriteAs := app.Config().WriteAsOauth.ClientID != "" |
|
|
|
|
|
|
|
|
|
|
|
oauthAccounts, err := app.db.GetOauthAccounts(r.Context(), u.ID) |
|
|
|
oauthAccounts, err := app.db.GetOauthAccounts(r.Context(), u.ID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("Unable to get oauth accounts for settings: %s", err) |
|
|
|
log.Error("Unable to get oauth accounts for settings: %s", err) |
|
|
|
return impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve user data. The humans have been alerted."} |
|
|
|
return impart.HTTPError{http.StatusInternalServerError, "Unable to retrieve user data. The humans have been alerted."} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, oauthAccount := range oauthAccounts { |
|
|
|
|
|
|
|
switch oauthAccount.Provider { |
|
|
|
|
|
|
|
case "slack": |
|
|
|
|
|
|
|
enableOauthSlack = false |
|
|
|
|
|
|
|
case "write.as": |
|
|
|
|
|
|
|
enableOauthWriteAs = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
displayOauthSection := enableOauthSlack || enableOauthWriteAs || len(oauthAccounts) > 0 |
|
|
|
|
|
|
|
|
|
|
|
obj := struct { |
|
|
|
obj := struct { |
|
|
|
*UserPage |
|
|
|
*UserPage |
|
|
@ -1050,6 +1063,7 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err |
|
|
|
HasPass bool |
|
|
|
HasPass bool |
|
|
|
IsLogOut bool |
|
|
|
IsLogOut bool |
|
|
|
Suspended bool |
|
|
|
Suspended bool |
|
|
|
|
|
|
|
OauthSection bool |
|
|
|
OauthAccounts []oauthAccountInfo |
|
|
|
OauthAccounts []oauthAccountInfo |
|
|
|
OauthSlack bool |
|
|
|
OauthSlack bool |
|
|
|
OauthWriteAs bool |
|
|
|
OauthWriteAs bool |
|
|
@ -1059,9 +1073,10 @@ func viewSettings(app *App, u *User, w http.ResponseWriter, r *http.Request) err |
|
|
|
HasPass: passIsSet, |
|
|
|
HasPass: passIsSet, |
|
|
|
IsLogOut: r.FormValue("logout") == "1", |
|
|
|
IsLogOut: r.FormValue("logout") == "1", |
|
|
|
Suspended: fullUser.IsSilenced(), |
|
|
|
Suspended: fullUser.IsSilenced(), |
|
|
|
|
|
|
|
OauthSection: displayOauthSection, |
|
|
|
OauthAccounts: oauthAccounts, |
|
|
|
OauthAccounts: oauthAccounts, |
|
|
|
OauthSlack: app.Config().SlackOauth.ClientID != "", |
|
|
|
OauthSlack: enableOauthSlack, |
|
|
|
OauthWriteAs: app.Config().WriteAsOauth.ClientID != "", |
|
|
|
OauthWriteAs: enableOauthWriteAs, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
showUserPage(w, "settings", obj) |
|
|
|
showUserPage(w, "settings", obj) |
|
|
|