1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-16 18:01:37 +00:00

refactor(ui): standardize user variable naming and avoid a SQL query when only userID is used

- Use `user` everywhere, instead of sometimes `loggedUser`
- Delay the instantiation of some variables: no need to perform SQL queries for
  nothing.
- Remove a SQL query getting the whole user struct when only user.ID is used.
This commit is contained in:
Julien Voisin 2025-08-12 04:48:36 +02:00 committed by GitHub
parent 50c5996280
commit 5d9d0b2652
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 50 additions and 57 deletions

View file

@ -24,7 +24,6 @@ func (h *handler) oauth2Unlink(w http.ResponseWriter, r *http.Request) {
return
}
printer := locale.NewPrinter(request.UserLanguage(r))
provider := request.RouteStringParam(r, "provider")
if provider == "" {
slog.Warn("Invalid or missing OAuth2 provider")
@ -42,7 +41,6 @@ func (h *handler) oauth2Unlink(w http.ResponseWriter, r *http.Request) {
return
}
sess := session.New(h.store, request.SessionID(r))
user, err := h.store.UserByID(request.UserID(r))
if err != nil {
html.ServerError(w, r, err)
@ -55,6 +53,8 @@ func (h *handler) oauth2Unlink(w http.ResponseWriter, r *http.Request) {
return
}
sess := session.New(h.store, request.SessionID(r))
printer := locale.NewPrinter(request.UserLanguage(r))
if !hasPassword {
sess.NewFlashErrorMessage(printer.Print("error.unlink_account_without_password"))
html.Redirect(w, r, route.Path(h.router, "settings"))