Compare commits
No commits in common. "2d853b4739c20a62fc58e22949a9fc455da93948" and "469b033e2f5b00336282f85c142cc384e88c199b" have entirely different histories.
2d853b4739
...
469b033e2f
|
@ -97,14 +97,18 @@ export async function getUserInfo(id: string) {
|
||||||
userInfo = userInfoCache.get(tokenInfo.owner)
|
userInfo = userInfoCache.get(tokenInfo.owner)
|
||||||
else {
|
else {
|
||||||
let userInfoRequest = await fetchUserInfo(tokenInfo.token)
|
let userInfoRequest = await fetchUserInfo(tokenInfo.token)
|
||||||
|
console.log(`userinforequest with ${userInfoRequest.status}`)
|
||||||
if (!userInfoRequest.ok) {
|
if (!userInfoRequest.ok) {
|
||||||
// assume that token has expired.
|
// assume that token has expired.
|
||||||
// try fetching a new one
|
// try fetching a new one
|
||||||
|
console.log("refresh token", tokenInfo.refreshToken)
|
||||||
if (!tokenInfo.refreshToken) return // no refresh token. back out
|
if (!tokenInfo.refreshToken) return // no refresh token. back out
|
||||||
let token = await getNewToken({
|
let token = await getNewToken({
|
||||||
grant_type: "refresh_token",
|
grant_type: "refresh_token",
|
||||||
refresh_token: tokenInfo.refreshToken
|
refresh_token: tokenInfo.refreshToken
|
||||||
})
|
})
|
||||||
|
console.log("new token", token)
|
||||||
|
console.log("new reftoken", token?.refresh_token)
|
||||||
if (!token) return // refresh failed. back out
|
if (!token) return // refresh failed. back out
|
||||||
await prisma.token.update({
|
await prisma.token.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
|
@ -121,6 +125,7 @@ export async function getUserInfo(id: string) {
|
||||||
userInfo = await userInfoRequest.json()
|
userInfo = await userInfoRequest.json()
|
||||||
|
|
||||||
// update user
|
// update user
|
||||||
|
console.log('aaa')
|
||||||
await prisma.user.upsert({
|
await prisma.user.upsert({
|
||||||
where: {
|
where: {
|
||||||
userId: userInfo.sub,
|
userId: userInfo.sub,
|
||||||
|
@ -176,6 +181,7 @@ export async function getRequestUser(request: Request, cookies: Cookies) {
|
||||||
// could cache this, but lazy
|
// could cache this, but lazy
|
||||||
|
|
||||||
let userInfo = await (await fetchUserInfo(tokens.access_token)).json() as User
|
let userInfo = await (await fetchUserInfo(tokens.access_token)).json() as User
|
||||||
|
console.log(tokens.refresh_token)
|
||||||
// create a new token
|
// create a new token
|
||||||
let newToken = await prisma.token.create({
|
let newToken = await prisma.token.create({
|
||||||
data: {
|
data: {
|
||||||
|
|
Loading…
Reference in a new issue