Skip to content

Commit f399b91

Browse files
authored
fix: Dashboard may display blank page when selecting an app after login (parse-community#2375)
1 parent 4062054 commit f399b91

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Parse-Dashboard/app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ module.exports = function(config, options) {
173173
}
174174

175175
app.get('/login', csrf(), function(req, res) {
176-
const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1];
176+
const redirectURL = req.url.includes('?redirect=') && req.url.split('?redirect=')[1].length > 1 && req.url.split('?redirect=')[1];
177177
if (!users || (req.user && req.user.isAuthenticated)) {
178178
return res.redirect(`${mountPath}${redirectURL || 'apps'}`);
179179
}
@@ -207,7 +207,11 @@ module.exports = function(config, options) {
207207
// For every other request, go to index.html. Let client-side handle the rest.
208208
app.get('/*', function(req, res) {
209209
if (users && (!req.user || !req.user.isAuthenticated)) {
210-
return res.redirect(`${mountPath}login?redirect=${req.url.replace('/login', '')}`);
210+
const redirect = req.url.replace('/login', '');
211+
if (redirect.length > 1) {
212+
return res.redirect(`${mountPath}login?redirect=${redirect}`);
213+
}
214+
return res.redirect(`${mountPath}login`);
211215
}
212216
if (users && req.user && req.user.matchingUsername ) {
213217
res.append('username', req.user.matchingUsername);

src/dashboard/DashboardView.react.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ export default class DashboardView extends React.Component {
3232
}
3333

3434
onRouteChanged() {
35-
const appId = this.context.applicationId;
3635
const path = this.props.location?.pathname ?? window.location.pathname;
37-
const route = path.split(appId)[1].split('/')[1];
36+
const route = path.split('apps')[1].split('/')[2];
3837
if (route !== this.state.route) {
3938
this.setState({ route });
4039
}

src/login/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class Login extends React.Component {
3434
forgot: false,
3535
username: sessionStorage.getItem('username') || '',
3636
password: sessionStorage.getItem('password') || '',
37-
redirect
37+
redirect: redirect !== '/' ? redirect : undefined
3838
};
3939
sessionStorage.clear();
4040
setBasePath(props.path);

0 commit comments

Comments
 (0)