Sharing of configuration and other authorizations
This commit is contained in:
@ -99,6 +99,13 @@ export function revokeAuthorization(){
|
||||
}
|
||||
}
|
||||
|
||||
export function importAuthorization(authorization){
|
||||
return {
|
||||
type: 'GENIUS_IMPORT_AUTHORIZATION',
|
||||
authorization: authorization
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current user
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
var helpers = require('./../../helpers')
|
||||
var coreActions = require('../core/actions')
|
||||
var helpers = require('./../../helpers');
|
||||
var coreActions = require('../core/actions');
|
||||
var geniusActions = require('./actions');
|
||||
|
||||
const GeniusMiddleware = (function(){
|
||||
return store => next => action => {
|
||||
@ -38,6 +39,15 @@ const GeniusMiddleware = (function(){
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'GENIUS_IMPORT_AUTHORIZATION':
|
||||
|
||||
// Wait a few moments before we fetch, allowing the import to complete first
|
||||
// TODO: Use callbacks for better code accuracy
|
||||
setTimeout(() => {store.dispatch(geniusActions.getMe())}, 100);
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
|
||||
@ -27,6 +27,15 @@ export default function reducer(genius = {}, action){
|
||||
me: null
|
||||
});
|
||||
|
||||
case 'GENIUS_IMPORT_AUTHORIZATION':
|
||||
return Object.assign({}, genius, {
|
||||
authorizing: false,
|
||||
authorization: action.authorization,
|
||||
authorization_code: action.authorization.authorization_code,
|
||||
access_token: action.authorization.access_token,
|
||||
me: null
|
||||
})
|
||||
|
||||
default:
|
||||
return genius
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user