#195: use replace state, when navigating to permissions from oauth entry point

This commit is contained in:
SleepWalker
2016-08-27 17:36:33 +03:00
parent 8cd00a5c40
commit 5ed38e0716
4 changed files with 37 additions and 6 deletions

View File

@@ -23,7 +23,12 @@ export default class AuthFlow {
}
setStore(store) {
this.navigate = (route) => {
/**
* @param {string} route
* @param {object} options
* @param {object} options.replace
*/
this.navigate = (route, options = {}) => {
if (this.getRequest().path !== route) {
this.currentRequest = {
path: route
@@ -32,7 +37,7 @@ export default class AuthFlow {
if (this.replace) {
this.replace(route);
}
store.dispatch(routeActions.push(route)); // TODO: may be deleted?
store.dispatch(routeActions[options.replace ? 'replace' : 'push'](route));
}
this.replace = null;

View File

@@ -3,7 +3,11 @@ import CompleteState from './CompleteState';
export default class PermissionsState extends AbstractState {
enter(context) {
context.navigate('/oauth/permissions');
context.navigate('/oauth/permissions', {
// replacing oauth entry point if currently on it
// to allow user easy go-back action to client's site
replace: context.getRequest().path.includes('oauth2')
});
}
resolve(context) {