mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-29 08:20:21 +05:30
#195: add custom description support for oauth
This commit is contained in:
parent
f2d2589550
commit
dc168b5f23
@ -133,9 +133,20 @@ export function logout() {
|
|||||||
return logoutUser();
|
return logoutUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to oAuth actions?
|
/**
|
||||||
// test request: /oauth?client_id=ely&redirect_uri=http%3A%2F%2Fely.by&response_type=code&scope=minecraft_server_session
|
* @param {object} oauthData
|
||||||
|
* @param {string} oauthData.clientId
|
||||||
|
* @param {string} oauthData.redirectUrl
|
||||||
|
* @param {string} oauthData.responseType
|
||||||
|
* @param {string} oauthData.description
|
||||||
|
* @param {string} oauthData.scope
|
||||||
|
* @param {string} oauthData.state
|
||||||
|
*
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
export function oAuthValidate(oauthData) {
|
export function oAuthValidate(oauthData) {
|
||||||
|
// TODO: move to oAuth actions?
|
||||||
|
// test request: /oauth?client_id=ely&redirect_uri=http%3A%2F%2Fely.by&response_type=code&scope=minecraft_server_session&description=foo
|
||||||
return wrapInLoader((dispatch) =>
|
return wrapInLoader((dispatch) =>
|
||||||
oauth.validate(oauthData)
|
oauth.validate(oauthData)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
@ -175,9 +186,9 @@ export function oAuthComplete(params = {}) {
|
|||||||
dispatch(requirePermissionsAccept());
|
dispatch(requirePermissionsAccept());
|
||||||
|
|
||||||
return Promise.reject(resp);
|
return Promise.reject(resp);
|
||||||
} else {
|
|
||||||
return handleOauthParamsValidation(resp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handleOauthParamsValidation(resp);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,23 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @param {object} oauthData
|
||||||
|
* @param {string} oauthData.clientId
|
||||||
|
* @param {string} oauthData.redirectUrl
|
||||||
|
* @param {string} oauthData.responseType
|
||||||
|
* @param {string} oauthData.description
|
||||||
|
* @param {string} oauthData.scope
|
||||||
|
* @param {string} oauthData.state
|
||||||
|
*
|
||||||
|
* @return {object}
|
||||||
|
*/
|
||||||
function getOAuthRequest(oauthData) {
|
function getOAuthRequest(oauthData) {
|
||||||
return {
|
return {
|
||||||
client_id: oauthData.clientId,
|
client_id: oauthData.clientId,
|
||||||
redirect_uri: oauthData.redirectUrl,
|
redirect_uri: oauthData.redirectUrl,
|
||||||
response_type: oauthData.responseType,
|
response_type: oauthData.responseType,
|
||||||
|
description: oauthData.description,
|
||||||
scope: oauthData.scope,
|
scope: oauthData.scope,
|
||||||
state: oauthData.state
|
state: oauthData.state
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@ export default class OAuthState extends AbstractState {
|
|||||||
clientId: query.client_id || params.clientId,
|
clientId: query.client_id || params.clientId,
|
||||||
redirectUrl: query.redirect_uri,
|
redirectUrl: query.redirect_uri,
|
||||||
responseType: query.response_type,
|
responseType: query.response_type,
|
||||||
|
description: query.description,
|
||||||
scope: query.scope,
|
scope: query.scope,
|
||||||
state: query.state
|
state: query.state
|
||||||
}).then(() => context.setState(new CompleteState()));
|
}).then(() => context.setState(new CompleteState()));
|
||||||
|
@ -100,7 +100,7 @@ describe('components/auth/actions', () => {
|
|||||||
|
|
||||||
return callThunk(oAuthComplete).then(() => {
|
return callThunk(oAuthComplete).then(() => {
|
||||||
expect(request.post, 'to have a call satisfying', [
|
expect(request.post, 'to have a call satisfying', [
|
||||||
'/api/oauth2/v1/complete?client_id=&redirect_uri=&response_type=&scope=&state=',
|
'/api/oauth2/v1/complete?client_id=&redirect_uri=&response_type=&description=&scope=&state=',
|
||||||
{}
|
{}
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,7 @@ describe('OAuthState', () => {
|
|||||||
client_id: 'client_id',
|
client_id: 'client_id',
|
||||||
redirect_uri: 'redirect_uri',
|
redirect_uri: 'redirect_uri',
|
||||||
response_type: 'response_type',
|
response_type: 'response_type',
|
||||||
|
description: 'description',
|
||||||
scope: 'scope',
|
scope: 'scope',
|
||||||
state: 'state'
|
state: 'state'
|
||||||
};
|
};
|
||||||
@ -39,6 +40,7 @@ describe('OAuthState', () => {
|
|||||||
clientId: query.client_id,
|
clientId: query.client_id,
|
||||||
redirectUrl: query.redirect_uri,
|
redirectUrl: query.redirect_uri,
|
||||||
responseType: query.response_type,
|
responseType: query.response_type,
|
||||||
|
description: query.description,
|
||||||
scope: query.scope,
|
scope: query.scope,
|
||||||
state: query.state
|
state: query.state
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user