Skip to content

Commit 87f0359

Browse files
fix(auth): invalid verify route in telegram plugin
1 parent ad7d0dd commit 87f0359

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backend",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"description": "PoliNetwork backend server",
55
"private": true,
66
"keywords": [],

backend/src/auth/plugins/telegram/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const telegramPlugin = () => {
3838
{
3939
method: "POST",
4040
use: [sessionMiddleware],
41-
body: linkBody
41+
body: linkBody,
4242
},
4343
async (ctx) => {
4444
const userId = ctx.context.session?.user.id;
@@ -66,10 +66,13 @@ export const telegramPlugin = () => {
6666
},
6767
),
6868
verifyLink: createAuthEndpoint(
69-
"/telegram/link/verify/:code",
69+
"/telegram/link/verify",
7070
{
7171
method: "GET",
72-
use: [sessionMiddleware]
72+
use: [sessionMiddleware],
73+
query: z.object({
74+
code: z.string().length(CODE_LENGTH).regex(/^\d+$/),
75+
}),
7376
},
7477
async (ctx) => {
7578
const userId = ctx.context.session?.user.id;
@@ -78,12 +81,7 @@ export const telegramPlugin = () => {
7881
message: "You must be authenticated",
7982
});
8083

81-
const code = ctx.params?.code;
82-
if (!code || code.length !== CODE_LENGTH || /^\d+$/.test(code))
83-
return ctx.error("BAD_REQUEST", {
84-
message: "The code must be a 6-digit string",
85-
});
86-
84+
const code = ctx.query.code;
8785
const res = await DB.select()
8886
.from(SCHEMA.TG.link)
8987
.where((t) => eq(t.code, code));

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polinetwork/backend",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"description": "Utils to interact with the backend.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)