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:
parent
50c5996280
commit
5d9d0b2652
11 changed files with 50 additions and 57 deletions
|
@ -20,10 +20,6 @@ import (
|
|||
)
|
||||
|
||||
func (h *handler) oauth2Callback(w http.ResponseWriter, r *http.Request) {
|
||||
clientIP := request.ClientIP(r)
|
||||
printer := locale.NewPrinter(request.UserLanguage(r))
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
|
||||
provider := request.RouteStringParam(r, "provider")
|
||||
if provider == "" {
|
||||
slog.Warn("Invalid or missing OAuth2 provider")
|
||||
|
@ -68,6 +64,9 @@ func (h *handler) oauth2Callback(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
printer := locale.NewPrinter(request.UserLanguage(r))
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
|
||||
if request.IsAuthenticated(r) {
|
||||
loggedUser, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
|
@ -124,6 +123,7 @@ func (h *handler) oauth2Callback(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
clientIP := request.ClientIP(r)
|
||||
sessionToken, _, err := h.store.CreateUserSessionFromUsername(user.Username, r.UserAgent(), clientIP)
|
||||
if err != nil {
|
||||
html.ServerError(w, r, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue