fix: accept token as query param in authenticate, pass token to oauth link URL
This commit is contained in:
@@ -277,7 +277,12 @@ export function SettingsPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!m.active && m.type !== 'password' && (
|
{!m.active && m.type !== 'password' && (
|
||||||
<Button size="small" variant="outlined" component="a" href={`/api/auth/oauth/${m.type}/link`}>
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
component="a"
|
||||||
|
href={`/api/auth/oauth/${m.type}/link?token=${localStorage.getItem('craftshop_auth_token') || ''}`}
|
||||||
|
>
|
||||||
Привязать
|
Привязать
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Binary file not shown.
@@ -75,6 +75,9 @@ await fastify.register(fastifyStatic, {
|
|||||||
|
|
||||||
fastify.decorate('authenticate', async function authenticate(request, reply) {
|
fastify.decorate('authenticate', async function authenticate(request, reply) {
|
||||||
try {
|
try {
|
||||||
|
if (!request.headers.authorization && request.query?.token) {
|
||||||
|
request.headers.authorization = `Bearer ${request.query.token}`
|
||||||
|
}
|
||||||
await request.jwtVerify()
|
await request.jwtVerify()
|
||||||
} catch {
|
} catch {
|
||||||
return reply.code(401).send({ error: 'Не авторизован' })
|
return reply.code(401).send({ error: 'Не авторизован' })
|
||||||
|
|||||||
Reference in New Issue
Block a user