update filemanager navigation

This commit is contained in:
Kenta420 2024-02-20 15:01:43 +07:00
parent 11dc6b2132
commit 92b11f7b9d
31 changed files with 363 additions and 305 deletions

View file

@ -4,13 +4,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/go-chi/chi/v5"
"golang.org/x/oauth2"
"net/http"
"recipe-manager/enums/permissions"
"recipe-manager/models"
"recipe-manager/services/oauth"
"recipe-manager/services/user"
"github.com/go-chi/chi/v5"
"golang.org/x/oauth2"
)
// ========================== ValidatePermissions =========================================
@ -20,6 +21,8 @@ func Authorize(oauthService oauth.OAuthService, userService user.UserService, ne
if cookie, err := r.Cookie("access_token"); err == nil {
token.AccessToken = cookie.Value
} else {
token.AccessToken = r.Header.Get("X-Access-Token")
}
userInfo, err := oauthService.GetUserInfo(r.Context(), token)
@ -28,6 +31,8 @@ func Authorize(oauthService oauth.OAuthService, userService user.UserService, ne
// if have refresh token, set refresh token to token
if cookie, err := r.Cookie("refresh_token"); err == nil {
token.RefreshToken = cookie.Value
} else {
token.RefreshToken = r.Header.Get("X-Refresh-Token")
}
newToken, err := oauthService.RefreshToken(r.Context(), token)