mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
feat(login): redirect mechanism - in page link to open popup
This commit is contained in:
@@ -23,14 +23,18 @@ export class AuthManager {
|
||||
: '/SASLogon/logout.do?'
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens Pop up window to SAS Login screen.
|
||||
* And checks if user has finished login process.
|
||||
*/
|
||||
public async redirectedLogIn() {
|
||||
const loginPopup = openWebPage(this.loginPreventRedirectUrl, 'SASLogon', {
|
||||
width: 500,
|
||||
height: 600
|
||||
})
|
||||
const loginPopup = await openWebPage(
|
||||
this.loginPreventRedirectUrl,
|
||||
'SASLogon',
|
||||
{ width: 500, height: 600 }
|
||||
)
|
||||
|
||||
if (!loginPopup) {
|
||||
alert('Unable to open popup for login. Please try with other browser.')
|
||||
return { isLoggedIn: false }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { openLoginPrompt } from '../utils/loginPrompt'
|
||||
|
||||
interface windowFeatures {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export function openWebPage(
|
||||
export async function openWebPage(
|
||||
url: string,
|
||||
windowName: string = '',
|
||||
{ width, height }: windowFeatures
|
||||
): Window | null {
|
||||
): Promise<Window | null> {
|
||||
const left = screen.width / 2 - width / 2
|
||||
const top = screen.height / 2 - height / 2
|
||||
|
||||
@@ -17,5 +19,16 @@ export function openWebPage(
|
||||
`toolbar=0,location=0,menubar=0,width=${width},height=${height},left=${left},top=${top}`
|
||||
)
|
||||
|
||||
if (!loginPopup) {
|
||||
const doLogin = await openLoginPrompt()
|
||||
return doLogin
|
||||
? window.open(
|
||||
url,
|
||||
windowName,
|
||||
`toolbar=0,location=0,menubar=0,width=${width},height=${height},left=${left},top=${top}`
|
||||
)
|
||||
: null
|
||||
}
|
||||
|
||||
return loginPopup
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user