experiment some thing spicy

This commit is contained in:
Kenta420 2023-12-01 11:14:25 +07:00
parent ce28a757b1
commit 3411ae333d
18 changed files with 211 additions and 10 deletions

View file

@ -10,6 +10,7 @@ import (
"recipe-manager/services/oauth"
"github.com/go-chi/chi/v5"
"go.uber.org/zap"
"golang.org/x/oauth2"
)
@ -87,6 +88,8 @@ func (ar *AuthRouter) Route(r chi.Router) {
value.Add("redirect_to", redirect_to)
}
Log.Info("User Log-In Success", zap.String("user", user.Name), zap.String("email", user.Email))
// redirect to frontend with token and refresh token
w.Header().Add("set-cookie", "access_token="+token.AccessToken+"; Path=/; HttpOnly; SameSite=None; Secure; Max-Age=3600")
w.Header().Add("set-cookie", "refresh_token="+token.RefreshToken+"; Path=/; HttpOnly; SameSite=None; Secure")

View file

@ -303,7 +303,7 @@ func (rr *RecipeRouter) Route(r chi.Router) {
// check if changed
// Log.Debug("Check if changed", zap.Any("result", rr.data.GetRecipe01ByProductCode(changes.ProductCode)))
file, _ := os.Create(path.Join("./cofffeemachineConfig", countryID[:3], filename))
file, _ := os.Create(path.Join("./cofffeemachineConfig", countryID, filename))
if err != nil {
Log.Error("Error when tried to create file", zap.Error(err))
return
@ -311,7 +311,7 @@ func (rr *RecipeRouter) Route(r chi.Router) {
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
err = encoder.Encode(rr.data.GetCurrentRecipe())
err = encoder.Encode(rr.data.GetRecipe(countryID, filename))
if err != nil {
Log.Error("Error when write file", zap.Error(err))