add configuration of auth: scope separator, client id, client secret, app name, reaml, additionalQueryParams

This commit is contained in:
Anna Bodnia
2017-05-11 16:30:30 +03:00
parent 5f6320e754
commit 8aebea34c4
11 changed files with 83 additions and 31 deletions

View File

@@ -7,6 +7,7 @@ export const LOGOUT = "logout"
export const PRE_AUTHORIZE_OAUTH2 = "pre_authorize_oauth2"
export const AUTHORIZE_OAUTH2 = "authorize_oauth2"
export const VALIDATE = "validate"
export const CONFIGURE_AUTH = "configure_auth"
const scopeSeparator = " "
@@ -117,8 +118,14 @@ export const authorizeAccessCode = ( auth ) => ( { authActions } ) => {
}
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions } ) => {
export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => {
let { body, query={}, headers={}, name, url, auth } = data
let { additionalQueryStringParams } = authSelectors.getConfigs() || {}
let fetchUrl = url
for (let key in additionalQueryStringParams) {
url += "&" + key + "=" + encodeURIComponent(additionalQueryStringParams[key])
}
let _headers = Object.assign({
"Accept":"application/json, text/plain, */*",
@@ -127,7 +134,7 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions } )
}, headers)
fn.fetch({
url: url,
url: fetchUrl,
method: "post",
headers: _headers,
query: query,
@@ -169,3 +176,10 @@ export const authorizeRequest = ( data ) => ( { fn, authActions, errActions } )
message: err.message
} ) })
}
export function configureAuth(payload) {
return {
type: CONFIGURE_AUTH,
payload: payload
}
}