mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-24 17:44:50 +03:00
authentication: actually catch the error when the viewer model fails to initialize
This commit is contained in:
parent
2ce2a15a28
commit
59620f60e8
@ -120,11 +120,7 @@ export default class ApplicationPage extends React.Component {
|
||||
}
|
||||
|
||||
// NOTE(jim): Only allow the sidebar to show with file drag and drop.
|
||||
if (
|
||||
e.dataTransfer.items &&
|
||||
e.dataTransfer.items.length &&
|
||||
e.dataTransfer.items[0].kind !== "file"
|
||||
) {
|
||||
if (e.dataTransfer.items && e.dataTransfer.items.length && e.dataTransfer.items[0].kind !== "file") {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -212,12 +208,13 @@ export default class ApplicationPage extends React.Component {
|
||||
rehydrate = async (options) => {
|
||||
const response = await Actions.hydrateAuthenticatedUser();
|
||||
|
||||
console.log("REHYDRATION CALL", response);
|
||||
|
||||
if (!response || response.error) {
|
||||
alert("TODO: error fetching authenticated viewer");
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log("REHYDRATION CALL", response);
|
||||
|
||||
const updates = {
|
||||
viewer: State.getInitialState(response.data),
|
||||
selected: State.getSelectedState(response.data),
|
||||
@ -277,8 +274,7 @@ export default class ApplicationPage extends React.Component {
|
||||
_handleDeleteYourself = async () => {
|
||||
// TODO(jim):
|
||||
// Put this somewhere better for messages.
|
||||
const message =
|
||||
"Do you really want to delete your account? It will be permanently removed";
|
||||
const message = "Do you really want to delete your account? It will be permanently removed";
|
||||
if (!window.confirm(message)) {
|
||||
return false;
|
||||
}
|
||||
@ -449,12 +445,8 @@ export default class ApplicationPage extends React.Component {
|
||||
<WebsitePrototypeWrapper
|
||||
title="Slate: sign in"
|
||||
description="Sign in to your Slate account to manage your assets."
|
||||
url="https://slate.host/_"
|
||||
>
|
||||
<SceneSignIn
|
||||
onAuthenticate={this._handleAuthenticate}
|
||||
onNavigateTo={this._handleNavigateTo}
|
||||
/>
|
||||
url="https://slate.host/_">
|
||||
<SceneSignIn onAuthenticate={this._handleAuthenticate} onNavigateTo={this._handleNavigateTo} />
|
||||
</WebsitePrototypeWrapper>
|
||||
);
|
||||
}
|
||||
@ -527,17 +519,12 @@ export default class ApplicationPage extends React.Component {
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<WebsitePrototypeWrapper
|
||||
description={description}
|
||||
title={title}
|
||||
url={url}
|
||||
>
|
||||
<WebsitePrototypeWrapper description={description} title={title} url={url}>
|
||||
<ApplicationLayout
|
||||
header={headerElement}
|
||||
navigation={navigationElement}
|
||||
sidebar={sidebarElement}
|
||||
onDismissSidebar={this._handleDismissSidebar}
|
||||
>
|
||||
onDismissSidebar={this._handleDismissSidebar}>
|
||||
{scene}
|
||||
</ApplicationLayout>
|
||||
<System.GlobalCarousel />
|
||||
|
@ -11,14 +11,14 @@ export default async (req, res) => {
|
||||
|
||||
const id = Utilities.getIdFromCookie(req);
|
||||
if (!id) {
|
||||
return res
|
||||
.status(500)
|
||||
.json({ decorator: "SERVER_HYDRATE_FAILURE", error: true });
|
||||
return res.status(500).json({ decorator: "SERVER_HYDRATE_FAILURE", error: true });
|
||||
}
|
||||
|
||||
const data = await ViewerManager.getById({ id });
|
||||
|
||||
return res
|
||||
.status(200)
|
||||
.send({ decorator: "SERVER_HYDRATE", success: true, data });
|
||||
if (!data) {
|
||||
return res.status(500).json({ decorator: "SERVER_VIEWER_DATA_ERROR", error: true, data: null });
|
||||
}
|
||||
|
||||
return res.status(200).send({ decorator: "SERVER_HYDRATE", success: true, data });
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user