Skip to content

Commit

Permalink
Fix lint and build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Sep 12, 2024
1 parent 2a95ee5 commit 249c46a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 0 additions & 4 deletions dashboard/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ watch(
}
)
asyncComputed(async () => {
fetch(ServerWithCompressConfigurator.DEFAULT_SERVER_URL + "/userinfo").then((response) => console.log(response))
})
const persistentStateManager = new PersistentStateManager("common", { serverUrl: ServerWithCompressConfigurator.DEFAULT_SERVER_URL })
persistentStateManager.add("serverUrl", serverUrl)
</script>
5 changes: 5 additions & 0 deletions dashboard/new-dashboard/src/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import Menu from "primevue/menu"
import { computed, ref, useTemplateRef } from "vue"
import { useRouter } from "vue-router"
import { getNavigationElement, PRODUCTS } from "./routes"
import { ServerWithCompressConfigurator } from "./configurators/ServerWithCompressConfigurator"
const currentPath = useRouter().currentRoute
const products = PRODUCTS.map((product) => ({ ...product, url: product.children[0].tabs[0].url })) //default to the first element in the first subproject
Expand Down Expand Up @@ -86,4 +87,8 @@ const selectedSubMenu = computed(() => {
function toggleSubMenu(event: MouseEvent) {
subMenu.value?.toggle(event)
}
asyncComputed(async () => {
fetch(ServerWithCompressConfigurator.DEFAULT_SERVER_URL + "/userinfo").then((response) => console.log(response))
})
</script>
13 changes: 9 additions & 4 deletions pkg/server/auth/handlers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package auth

import (
"context"
"encoding/json"
"io"
"net/http"
Expand All @@ -26,19 +27,23 @@ func CreateGetUserInfoHandler() http.HandlerFunc {
return
}

userInfo, err := fetchUserInfo(accessToken)
userInfo, err := fetchUserInfo(r.Context(), accessToken)
if err != nil {
http.Error(w, "Failed to fetch user info", http.StatusInternalServerError)
return
}

json.NewEncoder(w).Encode(userInfo)
err = json.NewEncoder(w).Encode(userInfo)
if err != nil {
http.Error(w, "Failed to parse user info", http.StatusInternalServerError)
return
}
}
}

func fetchUserInfo(accessToken string) (*UserInfo, error) {
func fetchUserInfo(ctx context.Context, accessToken string) (*UserInfo, error) {
client := &http.Client{}
req, err := http.NewRequest("GET", "https://www.googleapis.com/oauth2/v2/userinfo", nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://www.googleapis.com/oauth2/v2/userinfo", http.NoBody)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 249c46a

Please sign in to comment.