Hello :star: I am trying to build a function where...
# gooddata-ui
n
Hello I am trying to build a function where the user can reset his/her password, is that possible with any interface from the @gooddata/sdk-backend-spi? Thank you in advance 🌟
d
Hello Nicole 🙂 at the moment the sdk-backend-spi does not have such a function. But if you are using the GoodData Platform, you could redirect the user to
your.gooddata.domain/account.html#/lostPassword
and the user can reset their password there. For GoodData.CN it might be more complicated as it depends on the Identity Provider used. Does that help?
n
@Dan Homola It does help, thank you! Is there a way for me to retrieve the users password with the @gooddata/sdk-backend-spi? Is there a function i can call to retrieve the users password? I have called these two functions
console.log('Test 1: ', await backend.currentUser().getUser());
console.log('Test 2: ', await backend.currentUser().settings().getSettings());
But i dont get the users password 👀
d
No, there is not, we do not store users’ passwords in plaintext, so there is no way for us to even know the users password.
n
Thank You @Dan Homola! My next question is, what function can i use to retrieve a dashboard ID from a user? 👀
d
What do you mean by “dashboard ID from a user”? Can you please describe the use case in some more detail?
n
@Dan Homola so for example. In my web-app i want to display a users dashboard. My code for that currently looks like this:
Copy code
<div style={{ height: 300 }}>
	{/* <InsightView insight={Md.Insights.BrandrScoreBySurvey} /> */}
	<Dashboard dashboard={idRef("D"ASBOARD_ID)} />;
</div>
@Dan Homola I have hard coded in the Dashboard ID into my code, but i want to retrieve the Dashboard id from the backed.
d
Right, you can use somthing like this:
Copy code
import React, { useEffect, useState } from "react";

import { useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
import { Dashboard } from "@gooddata/sdk-ui-dashboard";

export const Example = () => {
    const backend = useBackendStrict();
    const workspace = useWorkspaceStrict();

    const [dashboard, setDashboard] = useState();

    useEffect(() => {
        const body = async () => {
            const allDashboards = await backend.workspace(workspace).dashboards().getDashboards();
            const chosenDashboard = allDashboards.find((dash) => {
                /* some logic */
            });

            setDashboard(chosenDashboard);
        };

        body();
    }, [backend, workspace]);

    return dashboard ? (
        <div style={{ height: 300 }}>
            <Dashboard dashboard={dashboard.ref} />;
        </div>
    ) : (
        <div>Loading</div>
    );
};
n
@Dan Homola Thank you so much i will try this!! How does it work if a user has multiple workspaces? For example, i do not want to hard code in each workspace in my code, is there a function to retrieve multiple workspaces? 🌟
d
Yes, there is
backend.workspaces().forCurrentUser()
that has some functions for iterating through the available workspaces for the currently logged in user. See the API reference you can find information about the other available functions there as well 🙂
n
@Dan Homola Thank you for your help 🥳 If i want to retrieve only one widget from the dashboard is that possible? I tried writing the name of the widget, just like your supposed to do when you retrieve an insight but that didint work, is there a function for that? or is there a widget id for each widget? 🌟
d
No problem 🙂 no tat is not possible, the widgets are only available as part of a dashboard
n
@Dan Homola Thank you so in order for me to show only one widget i would have to create them as insights?
d
If you want to show some widgets from a dashboard, then yes, probably showing them using an InsightView might be the easiest
n
@Dan Homola Thank you! Your answers cleared it up for me a bit more
d
No problem, glad I could help 🙂
🥳 1
n
@Dan Homola when trying the code i ran in to some thoughts. Is there a function where we can update the users password in good data? or maybe you answered that question before but i feel like i need some clarity on that
d
There is no function for that in the GoodData.UI, the user needs to do this change themselves: https://help.gooddata.com/pages/viewpage.action?pageId=86797174#PasswordPolicy-ChangePassword