Tracardi / tracardi-gui

Tracardi ReactJs Graphical User Interface
Other
19 stars 25 forks source link

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

Open atompie opened 1 year ago

atompie commented 1 year ago

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

developer-diganta commented 1 year ago

Can I work on this?

atompie commented 1 year ago

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

developer-diganta commented 1 year ago

@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?

atompie commented 1 year ago

@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 commented 1 year ago

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