1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 19:08:21 +00:00

don't turn to login page when 403 (#4323)

* don't turn to login page when 403

* [403] show login tip when 403 is returned
This commit is contained in:
llj
2019-12-05 15:45:16 +08:00
committed by Daniel Pan
parent ca794f934f
commit 7d7dc51821
86 changed files with 388 additions and 1397 deletions

View File

@@ -4,7 +4,7 @@ import cookie from 'react-cookies';
import MediaQuery from 'react-responsive';
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import { seafileAPI } from '../../utils/seafile-api';
import { gettext, loginUrl, canAddPublicRepo } from '../../utils/constants';
import { gettext, canAddPublicRepo } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import Repo from '../../models/repo';
import toaster from '../../components/toast';
@@ -52,25 +52,10 @@ class PublicSharedView extends React.Component {
repoList: Utils.sortRepos(repoList, this.state.sortBy, this.state.sortOrder)
});
}).catch((error) => {
if (error.response) {
if (error.response.status == 403) {
this.setState({
isLoading: false,
errMessage: gettext('Permission denied')
});
location.href = `${loginUrl}?next=${encodeURIComponent(location.href)}`;
} else {
this.setState({
isLoading: false,
errMessage: gettext('Error')
});
}
} else {
this.setState({
isLoading: false,
errMessage: gettext('Please check the network.')
});
}
this.setState({
isLoading: false,
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
});
});
}