tracardi-gui icon indicating copy to clipboard operation
tracardi-gui copied to clipboard

Set user preferences from that /token endpoint to browser local storage

Open atompie opened this issue 3 years ago • 5 comments

During login the user preferences are returned; safe them in localStorage. Create a class to easliy access them

class UserPreferece {
  get(key)
  set(key, pref)
  list()
}

set should use the API: https://github.com/Tracardi/tracardi/issues/704

atompie avatar Sep 20 '22 09:09 atompie

Can I work on this?

developer-diganta avatar Oct 03 '22 11:10 developer-diganta

Sure. Sorry for the late response. If you have more questions please do not hesitate to ask them here

atompie avatar Oct 06 '22 13:10 atompie

@atompie Hello! Wanted to know if what you meant to say was that after login is successful, store the credentials in the object of the described class and then save it to local storage? And is this the file where login is approved https://github.com/Tracardi/tracardi-gui/blob/master/src/components/authentication/SignIn.js?

developer-diganta avatar Oct 06 '22 21:10 developer-diganta

@developer-diganta Yes it is done here.

const api = loginUser(email, password);
        setProgress(true);
        api.then(response => {
            setToken(response.data['access_token']);
            setRoles(response.data['roles']);
            setStoredApiUrl(apiUrl);
            setRedirectToReferrer(true);
        })

See setToken it does the same thing.

Preferences should be returned with the response.

atompie avatar Oct 06 '22 22:10 atompie

Sorry for confusion this issue is still open. I clicked wrong button.

atompie avatar Oct 09 '22 12:10 atompie