mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +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();
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 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) =>
|
||||
oauth.validate(oauthData)
|
||||
.then((resp) => {
|
||||
@ -175,9 +186,9 @@ export function oAuthComplete(params = {}) {
|
||||
dispatch(requirePermissionsAccept());
|
||||
|
||||
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) {
|
||||
return {
|
||||
client_id: oauthData.clientId,
|
||||
redirect_uri: oauthData.redirectUrl,
|
||||
response_type: oauthData.responseType,
|
||||
description: oauthData.description,
|
||||
scope: oauthData.scope,
|
||||
state: oauthData.state
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ export default class OAuthState extends AbstractState {
|
||||
clientId: query.client_id || params.clientId,
|
||||
redirectUrl: query.redirect_uri,
|
||||
responseType: query.response_type,
|
||||
description: query.description,
|
||||
scope: query.scope,
|
||||
state: query.state
|
||||
}).then(() => context.setState(new CompleteState()));
|
||||
|
@ -100,7 +100,7 @@ describe('components/auth/actions', () => {
|
||||
|
||||
return callThunk(oAuthComplete).then(() => {
|
||||
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',
|
||||
redirect_uri: 'redirect_uri',
|
||||
response_type: 'response_type',
|
||||
description: 'description',
|
||||
scope: 'scope',
|
||||
state: 'state'
|
||||
};
|
||||
@ -39,6 +40,7 @@ describe('OAuthState', () => {
|
||||
clientId: query.client_id,
|
||||
redirectUrl: query.redirect_uri,
|
||||
responseType: query.response_type,
|
||||
description: query.description,
|
||||
scope: query.scope,
|
||||
state: query.state
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user