question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Properties USER change after reload

See original GitHub issue

Version

@nuxtjs/strapi: 0.3.1 nuxt: 2.15.8 with i18n active strapi: 3.6.8 with i18n active

Problem

I have on the “user” types collection add additional fields (sample: avatar type “single media images”) On the website, once connected, I find these additional fields in the user object. If I refresh website, these additional fields disappear.

Steps to reproduce

1- In admin strapi, create field “media” in collection “user” with this propertie:

  • base settings: avatar (name), single media (type)
  • advanced settings : images (type of media)

2- In website, create a login form who get user info:

const user = await this.$strapi.login({ identifier: this.model.username,  password: this.model.password, })

3- In another page of website, I get info of user

this.user = await this.$strapi.user
 console.log(this.user)

=> Result of log (OK), I have object “avatar”:

avatar: Object
blocked: false
confirmed: true
created_at: "2021-09-03T09:12:03.889Z"
email: "admin@example.com"
id: 1
initials: "at"
provider: "local"
role: Object
updated_at: "2021-09-08T12:39:39.982Z"

3- Now, I refresh my website with ‘F5’

this.user = await this.$strapi.user
 console.log(this.user)

=> Result of log (KO), I loose object “avatar”:

blocked: false
confirmed: true
created_at: "2021-09-03T09:12:03.889Z"
email: "admin@example.com"
id: 1
initials: "at"
provider: "local"
role: Object
updated_at: "2021-09-08T12:39:39.982Z"
username: "admin user test"

But with the another specific field “initials” (type “small text”), I don’t have a problem

Why object “user” loose the field “avatar” after refresh ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
tanlong14commented, Sep 30, 2021

@madsh93 OK thanks a lot I did not see the other request, sorry.

0reactions
tanlong14commented, Oct 2, 2021

The solution, if anyone needs it:

1- Create file “User.js” in folder: “./extensions/users-permissions/services/”

2- In file “User.js” write this:

module.exports = { async fetchAuthenticatedUser(id) { return strapi .query("user", "users-permissions") .findOne({ id }, ["role", "avatar"]); }, };

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reloading Properties Files in Spring - Baeldung
Learn a few approaches to getting property values to reload in Spring Beans, including Spring Cloud's refresh scope.
Read more >
Keep button properties after page reload - Stack Overflow
I want to keep button properties after page reload, o if the button was clicked and then the page was reloaded the button...
Read more >
Refresh editor properties when changes has been made in ...
I am performing some property changes via api calls to backend and i need to tell the editor to refresh its state. Right...
Read more >
chylex/Minecraft-Server-Properties-Reload - GitHub
Minecraft mod that reloads server.properties without restarting. ... only applies to users /op 'd after the change and does not affect existing operators....
Read more >
Reload and Hot Reload
You can instruct OWNER to automatically reload the properties files if they are modified on the filesystem. For instance: @HotReload @Sources("file:foo/bar/baz.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found