-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: fixed deleting page and login after refresh Page * fix: auth
- Loading branch information
Showing
9 changed files
with
189 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { db } from "../../db/db"; | ||
import { YoutubeWidget } from "../../db/schemas/widget"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
interface TRemoveWidgetResponse { | ||
id: number; | ||
} | ||
export const removeWidget = async ( | ||
id: number, | ||
): Promise<TRemoveWidgetResponse[] | null> => { | ||
try { | ||
return await db | ||
.delete(YoutubeWidget) | ||
.where(eq(YoutubeWidget.pageId, id)) | ||
.returning({ | ||
id: YoutubeWidget.id, | ||
}); | ||
} catch (e) { | ||
console.log(e); | ||
return null; | ||
} | ||
}; |
25 changes: 24 additions & 1 deletion
25
src/routes/tokenController/refreshToken/refreshTokenController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
import type { FastifyReply, FastifyRequest } from "fastify"; | ||
import { type TRequestLogin } from "./types"; | ||
import tokenService from "../../../services/tokenService"; | ||
import { type User } from "../../../services/userService/types"; | ||
|
||
const refreshTokenController = async ( | ||
request: FastifyRequest<TRequestLogin>, | ||
reply: FastifyReply, | ||
) => { | ||
return await tokenService.refreshToken(request, reply); | ||
const decodedToken = await request.jwtVerify({ | ||
decode: { | ||
complete: true, | ||
}, | ||
verify: { | ||
complete: true, | ||
}, | ||
}); | ||
|
||
if (!decodedToken) { | ||
return null; | ||
} | ||
console.log("decodedToken", decodedToken); | ||
if (typeof decodedToken !== "string" && "payload" in decodedToken) { | ||
const resp = await tokenService.refreshToken( | ||
decodedToken as { payload: User }, | ||
reply, | ||
); | ||
|
||
reply.send(resp); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default refreshTokenController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.