mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Заимплементил finish state
This commit is contained in:
@@ -151,6 +151,7 @@ export function oAuthComplete(params = {}) {
|
||||
if (resp.statusCode === 401 && resp.error === 'access_denied') {
|
||||
// user declined permissions
|
||||
return {
|
||||
success: false,
|
||||
redirectUri: resp.redirectUri
|
||||
};
|
||||
}
|
||||
@@ -168,6 +169,18 @@ export function oAuthComplete(params = {}) {
|
||||
error.acceptRequired = true;
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp.redirectUri === 'static_page' || resp.redirectUri === 'static_page_with_code') {
|
||||
resp.displayCode = resp.redirectUri === 'static_page_with_code';
|
||||
dispatch(setOAuthCode({
|
||||
success: resp.success,
|
||||
code: resp.code,
|
||||
displayCode: resp.displayCode
|
||||
}));
|
||||
}
|
||||
|
||||
return resp;
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -224,6 +237,18 @@ export function setOAuthRequest(oauth) {
|
||||
};
|
||||
}
|
||||
|
||||
export const SET_OAUTH_RESULT = 'set_oauth_result';
|
||||
export function setOAuthCode(oauth) {
|
||||
return {
|
||||
type: SET_OAUTH_RESULT,
|
||||
payload: {
|
||||
success: oauth.success,
|
||||
code: oauth.code,
|
||||
displayCode: oauth.displayCode
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const SET_SCOPES = 'set_scopes';
|
||||
export function setScopes(scopes) {
|
||||
if (!(scopes instanceof Array)) {
|
||||
|
||||
@@ -104,9 +104,9 @@ class Finish extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default connect((state) => ({
|
||||
appName: state.auth.client ? state.auth.client.name : 'Undefined',
|
||||
code: 'HW9vkZA6Y4vRN3ciSm1IIDk98PHLkPPlv3jvo1MX',
|
||||
displayCode: true,
|
||||
success: true
|
||||
export default connect(({auth}) => ({
|
||||
appName: auth.client.name,
|
||||
code: auth.oauth.code,
|
||||
displayCode: auth.oauth.displayCode,
|
||||
success: auth.oauth.success
|
||||
}))(Finish);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import { ERROR, SET_CLIENT, SET_OAUTH, SET_SCOPES } from './actions';
|
||||
import { ERROR, SET_CLIENT, SET_OAUTH, SET_OAUTH_RESULT, SET_SCOPES } from './actions';
|
||||
|
||||
export default combineReducers({
|
||||
error,
|
||||
@@ -56,6 +56,14 @@ function oauth(
|
||||
state: payload.state
|
||||
};
|
||||
|
||||
case SET_OAUTH_RESULT:
|
||||
return {
|
||||
...state,
|
||||
success: payload.success,
|
||||
code: payload.code,
|
||||
displayCode: payload.displayCode
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user