Skip to content

Commit

Permalink
shell: lib: handle cockpit.user() failures
Browse files Browse the repository at this point in the history
In our test TestLogin.testFailingWebsocket the dbus calls fail which
fails the promise which was unhandled leading to the tests to fail due
to an unhandled exception.
  • Loading branch information
jelly authored and martinpitt committed Mar 27, 2024
1 parent 376bfeb commit f2cc9e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function usePageLocation() {

const cockpit_user_promise = cockpit.user();
let cockpit_user = null;
cockpit_user_promise.then(user => { cockpit_user = user });
cockpit_user_promise.then(user => { cockpit_user = user }).catch(err => console.log(err));

export function useLoggedInUser() {
const [user, setUser] = useState(cockpit_user);
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/hosts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class CockpitHosts extends React.Component {
componentDidMount() {
cockpit.user().then(user => {
this.setState({ current_user: user.name || "" });
});
}).catch(exc => console.log(exc));
}

static getDerivedStateFromProps(nextProps, prevState) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/indexes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function MachinesIndex(index_options, machines, loader) {
let current_user = "";
cockpit.user().then(user => {
current_user = user.name || "";
});
}).catch(exc => console.log(exc));

/* Navigation */
let ready = false;
Expand Down

0 comments on commit f2cc9e1

Please sign in to comment.