Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to login #311

Open
FreePhoenix888 opened this issue Feb 16, 2024 · 0 comments
Open

Unable to login #311

FreePhoenix888 opened this issue Feb 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@FreePhoenix888
Copy link
Member

Code Snippet

https://github.com/FreePhoenix888/deeplinks-login-error-example/blob/4c54875189621d8ff31b1934fde4ea93e35f4235/test.js#L30-L33

Output

{
  newUserLoginResultBeforeJoin: { linkId: null, token: null, error: 'unexepted' }
}

Expected result

To login without a problem because this code is copied from the test that is currently working

deeplinks/tests/permissions.ts

Lines 1132 to 1171 in 427e406

it('create a new user, join to admin, insert type', async () => {
const unloginedDeep = new DeepClient({ apolloClient });
const guestLoginResult = await unloginedDeep.guest();
const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult });
const adminLogin = await guestDeep.login({
linkId: await guestDeep.id('deep', 'admin'),
});
console.log({ adminLogin })
const adminDeep = new DeepClient({ deep: guestDeep, ...adminLogin });
// console.log({ adminDeep })
const { data: [{ id: newUserLinkId }] } = await adminDeep.insert({
type_id: adminDeep.idLocal("@deep-foundation/core", "User")
})
const newUserLoginResultBeforeJoin = await unloginedDeep.login({
linkId: newUserLinkId
});
console.log({ newUserLoginResultBeforeJoin });
console.log({ newUserLoginResultBeforeJoinDecodedToken: parseJwt(newUserLoginResultBeforeJoin.token) });
const joinInsertData = {
type_id: adminDeep.idLocal("@deep-foundation/core", "Join"),
from_id: newUserLinkId,
to_id: adminDeep.linkId
}
console.log({ joinInsertData })
const joinInsertResult = await adminDeep.insert(joinInsertData)
console.log({ joinInsertResult });
const newUserLoginResultAfterJoin = await unloginedDeep.login({
linkId: newUserLinkId
});
console.log({ newUserLoginResultAfterJoin });
console.log({ newUserLoginResultAfterJoin: parseJwt(newUserLoginResultAfterJoin.token) });
const newUserDeep = new DeepClient({ deep: unloginedDeep, ...newUserLoginResultAfterJoin })
// console.log({ newUserDeep })
const insertResult = await newUserDeep.insert({
type_id: newUserDeep.idLocal("@deep-foundation/core", "Type")
})
console.log({ insertResult })
})

But for some reasons it does not work outside of deeplinks

Actual result

gitpod /workspace/dev/temp/bug (main) $ npx --yes tsx test.js
{
  adminLogin: {
    linkId: 380,
    token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsiYWRtaW4iXSwieC1oYXN1cmEtZGVmYXVsdC1yb2xlIjoiYWRtaW4iLCJ4LWhhc3VyYS11c2VyLWlkIjoiMzgwIn0sImlhdCI6MTcwODA2OTgwOH0.-fpP3Ijev5Zo9zFFqLi9BnueLvynk44Qjlx-rCJhNfY',
    error: undefined
  }
}
{
  newUserLoginResultBeforeJoin: { linkId: null, token: null, error: 'unexepted' }
}
{ joinInsertData: { type_id: 66, from_id: 1433, to_id: 380 } }
{ joinInsertResult: { data: [ [Object] ] } }
{
  newUserLoginResultAfterJoin: { linkId: null, token: null, error: 'unexepted' }
}
/workspace/dev/temp/bug/node_modules/@deep-foundation/deeplinks/imports/client.js:300
                throw new Error('token for apolloClient is invalid or not provided');
                      ^


Error: token for apolloClient is invalid or not provided
    at DeepClient (/workspace/dev/temp/bug/node_modules/@deep-foundation/deeplinks/imports/client.js:300:23)
    at main (/workspace/dev/temp/bug/test.js:47:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.17.1

Additional Info

Note that I use the latest deeplinks versions that is used for testing too

How to reproduce

git clone https://github.com/FreePhoenix888/deeplinks-login-error-example
cd deeplinks-login-error-example
npm install
npx --yes tsx test.js
@FreePhoenix888 FreePhoenix888 added the bug Something isn't working label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant