deep-foundation / deep-foundation/deeplinks

Why do we need separate role for admin users?

Open
#298 0 comments 1 reaction 1 assignee Claimed by @konard View on GitHub
bug problem question
Dominant language
TypeScript
Stars
13
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Now we have two roles:
```
link
admin
```

While solving https://github.com/deep-foundation/deeplinks/issues/297 we find out that, when we create a `Join` link between user and admin, and execute `deep.login` `role` and `roles` fields get modified inside JWT token:

```
console.log
{
newUserLoginResultBeforeJoin: {
linkId: 1811,
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsibGluayJdLCJ4LWhhc3VyYS1kZWZhdWx0LXJvbGUiOiJsaW5rIiwieC1oYXN1cmEtdXNlci1pZCI6IjE4MTEifSwiaWF0IjoxNzA2NTM3MTM0fQ.9wupvXbjIIwZX5PTEbXEjvgl6OXlafaeXlotpd8PWx8',
error: undefined
}
}

at log (tests/permissions.ts:1149:15)

console.log
{
newUserLoginResultBeforeJoinDecodedToken: { userId: 1811, role: 'link', roles: [ 'link' ] }
}
```

```
console.log
{
newUserLoginResultAfterJoin: {
linkId: 1811,
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsiYWRtaW4iXSwieC1oYXN1cmEtZGVmYXVsdC1yb2xlIjoiYWRtaW4iLCJ4LWhhc3VyYS11c2VyLWlkIjoiMTgxMSJ9LCJpYXQiOjE3MDY1MzcxMzR9.SSa4F643tSEy0oLXrFS7uCegN6Nw4wU5TYxnxI_PMBg',
error: undefined
}
}

at log (tests/permissions.ts:1163:15)

console.log
{
newUserLoginResultAfterJoin: { userId: 1811, role: 'admin', roles: [ 'admin' ] }
}
```

That means we have to relogin to gain admin permissions. But if there were only `link` role, there would be no problem (no need to relogin).

It also affects Deep.Case, we have to relogin there too, and it does not work by default as expected.

@ivansglazunov what do you think about it?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.