feat(oauth2): authActions.authPopup plugin accessible wrapper (#7699)
* enables win.open to be extensible by plugins Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import parseUrl from "url-parse"
|
||||
import win from "core/window"
|
||||
import Im from "immutable"
|
||||
import { btoa, sanitizeUrl, generateCodeVerifier, createCodeChallenge } from "core/utils"
|
||||
|
||||
@@ -123,13 +122,11 @@ export default function authorize ( { auth, authActions, errActions, configs, au
|
||||
callback = authActions.authorizeAccessCodeWithFormParams
|
||||
}
|
||||
|
||||
win.swaggerUIRedirectOauth2 = {
|
||||
authActions.authPopup(url, {
|
||||
auth: auth,
|
||||
state: state,
|
||||
redirectUrl: redirectUrl,
|
||||
callback: callback,
|
||||
errCb: errActions.newAuthErr
|
||||
}
|
||||
|
||||
win.open(url)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function authorize(payload) {
|
||||
|
||||
export const authorizeWithPersistOption = (payload) => ( { authActions } ) => {
|
||||
authActions.authorize(payload)
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
}
|
||||
|
||||
export function logout(payload) {
|
||||
@@ -41,7 +41,7 @@ export function logout(payload) {
|
||||
|
||||
export const logoutWithPersistOption = (payload) => ( { authActions } ) => {
|
||||
authActions.logout(payload)
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
}
|
||||
|
||||
export const preAuthorizeImplicit = (payload) => ( { authActions, errActions } ) => {
|
||||
@@ -85,7 +85,7 @@ export function authorizeOauth2(payload) {
|
||||
|
||||
export const authorizeOauth2WithPersistOption = (payload) => ( { authActions } ) => {
|
||||
authActions.authorizeOauth2(payload)
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
authActions.persistAuthorizationIfNeeded()
|
||||
}
|
||||
|
||||
export const authorizePassword = ( auth ) => ( { authActions } ) => {
|
||||
@@ -279,3 +279,9 @@ export const persistAuthorizationIfNeeded = () => ( { authSelectors, getConfigs
|
||||
localStorage.setItem("authorized", JSON.stringify(authorized.toJS()))
|
||||
}
|
||||
}
|
||||
|
||||
export const authPopup = (url, swaggerUIRedirectOauth2) => ( ) => {
|
||||
win.swaggerUIRedirectOauth2 = swaggerUIRedirectOauth2
|
||||
|
||||
win.open(url)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user