# Leaderboard Chart not rendering (unauthorised access to table)

**URL:** <https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413>\
**Category:** Help me!\
**Created:** [December 2, 2020, 5:59pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413 "2020-12-02T17:59:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 2, 2020, 5:59pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/1 "2020-12-02T17:59:05Z")

</div>

Hello,  
I’m fairly new to Forest  
I am trying to render a leaderbord Chart on my forest admin Dashboard showing the Number of tasks created per User…

## Expected behavior

Render a Leaderboard chart

## Actual behavior

Forest Admin cannot render this chart, syntax error at or near “.” The other charts on the page render correctly and I am able to render LeaderBoards on other tables. (this seems to be due to an unauthorised access to the users table)

## Failure Logs

When I look at the Chrome console, I get a 401 on this request “forest/stats/users” with the following error message "detail: “Forest cannot authenticate the user for this request.”

## Context

“body-parser”: “1.19.0”,  
“chalk”: “~1.1.3”,  
“cookie-parser”: “1.4.4”,  
“cors”: “2.8.5”,  
“debug”: “~4.0.1”,  
“dotenv”: “~6.1.0”,  
“express”: “~4.16.3”,  
“express-jwt”: “5.3.1”,  
“forest-express”: “^7.4.0”,  
“forest-express-sequelize”: “^6.0.0”,  
“morgan”: “1.9.1”,  
“require-all”: “^3.0.0”,  
“sequelize”: “~5.15.1”,  
“pg”: “~8.2.2”

Would you have any idea what might be causing this error ?

Thanks a lot for your help  
Chris

---

<div class="post-metadata">

**Author:** ![anon94532230](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@anon94532230](https://community.forestadmin.com/u/anon94532230)\
**Post date:** [December 3, 2020, 8:47am UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/2 "2020-12-03T08:47:38Z")

</div>

Hello @Christopher_Bagard !  
Can you share screenshots of your error logs (both in browser/console) and of your chart configuration ?

---

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 3, 2020, 10:24am UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/3 "2020-12-03T10:24:56Z")

</div>

Hi Nicolas,

Thank you for your fast answer. Here are the screenshots

 ![Capture d’écran 2020-12-03 à 11.19.32](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/7/7860293623305e5125514b09977c759044be0c5e.png) ![Capture d’écran 2020-12-03 à 11.21.11](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/a2aef149f0a66046db36f2d99068fb264cde1894.png) ![Capture d’écran 2020-12-03 à 11.23.16](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/65226e420feac403ddfd3622e03c9057c822ce73.png) ![Capture d’écran 2020-12-03 à 11.24.01](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/6014b487b4dcb7b02ac084b1ea30054d5b3d218a.png)

---

<div class="post-metadata">

**Author:** ![anon94532230](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@anon94532230](https://community.forestadmin.com/u/anon94532230)\
**Post date:** [December 3, 2020, 11:37am UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/4 "2020-12-03T11:37:45Z")

</div>

Can you please share the query that is triggered on your liana ? You should have one in dev looking like the following:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/9/997b3f715bb9b33c1f17bf0afa8ce49162875553.png)

---

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 4, 2020, 8:34am UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/5 "2020-12-04T08:34:22Z")

</div>

In dev, I directly get a Sequelize error

`POST /forest/stats/users 500 103 - 786.491 ms [forest] 🌳🌳🌳 Unexpected error: syntax error at or near "." SequelizeDatabaseError: syntax error at or near "."`

I am not sure where I can find for the raw sequel query.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [December 4, 2020, 1:41pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/6 "2020-12-04T13:41:26Z")

</div>

set `NODE_ENV='development'` in your `.env` file and you should be able to see the raw query 😉

---

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 4, 2020, 1:57pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/7 "2020-12-04T13:57:41Z")

</div>

> [@anon62739609](#):
>
> `NODE_ENV='development'`

Thanks got it !

```sql
SELECT COUNT("tasks"."id") as "value", user.lastname as "key"
FROM "tasks"
INNER JOIN "users" AS "user"
        ON "user"."id" = "tasks"."user_id"
    
GROUP BY user.lastname
ORDER BY "value" DESC
LIMIT 20

```

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [December 4, 2020, 2:14pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/8 "2020-12-04T14:14:24Z")

</div>

Hmm and if you replace `GROUP BY user.lastname` by `GROUP BY key` does it work 🤔?

---

<div class="post-metadata">

**Author:** ![bqst](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/bqst/32/1187_2.png) [@bqst](https://community.forestadmin.com/u/bqst)\
**Post date:** [December 7, 2020, 1:44pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/9 "2020-12-07T13:44:03Z")

</div>

Same problem here, it seems that there was a problem with the auto-generated SQL query from leaderboard chart:

```javascript
SELECT COUNT("tasks"."id") as "value", user.email as "key"
FROM "tasks"
INNER JOIN "users" AS "user"
ON "user"."id" = "tasks"."user_id"
GROUP BY user.email
ORDER BY "value" DESC
LIMIT 10

```

Fixed by adding the missing quotes around user.email and by manually filling in the “QUERY” field.

```javascript
SELECT COUNT("tasks"."id") as "value", "user"."email" as "key"
FROM "tasks"
INNER JOIN "users" AS "user"
ON "user"."id" = "tasks"."user_id"
GROUP BY "user"."email"
ORDER BY "value" DESC
LIMIT 10

```

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [December 7, 2020, 2:09pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/10 "2020-12-07T14:09:17Z")

</div>

Hi @bqst 👋 welcome to our community.  
Hi @Christopher_Bagard 👋 I reproduced your issue, the problems here is `user` is a reserved word on some DBMS. To access your database we must use quotes.  
So I will open a bug report on our side to fix this issue.

I’m happy to see you found a workaround 👍

I will keep you update when the fix was implemented.

---

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 7, 2020, 6:30pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/11 "2020-12-07T18:30:55Z")

</div>

Hey,  
thanks all (@Arnaud_Moncel, @bqst, @bqst, @anon62739609) for your prompts answers and the workound ! Will try it it out

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [December 9, 2020, 2:01pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/12 "2020-12-09T14:01:46Z")

</div>

Hi guys (@bqst, @Christopher_Bagard) a fix has been released, make sure you installed the `forest-express-sequelize >= 6.5.1`.  
Let me know if the issue persist.

---

<div class="post-metadata">

**Author:** ![Christopher\_Bagard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/christopher_bagard/32/1078_2.png) [@Christopher\_Bagard](https://community.forestadmin.com/u/Christopher_Bagard)\
**Post date:** [December 10, 2020, 5:22pm UTC](https://community.forestadmin.com/t/leaderboard-chart-not-rendering-unauthorised-access-to-table/1413/13 "2020-12-10T17:22:04Z")

</div>

> [@Arnaud\_Moncel](#):
>
> rest-express-sequelize \>

awesome ! this works, thanks a lot !
