1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-08 21:10:05 +00:00

chore: redirect login with onLoggedOut callback

This commit is contained in:
Saad Jutt
2021-08-31 12:36:20 +05:00
parent 389ef94cd5
commit f231edb4a6
4 changed files with 24 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import { ServerType } from '@sasjs/utils/types'
import { RequestClient } from '../request/RequestClient'
import { LoginOptions } from '../types/LoginOptions'
import { serialize } from '../utils'
import { openWebPage } from './openWebPage'
import { verifyingPopUpLoginSAS9 } from './verifyingPopUpLoginSAS9'
@@ -27,11 +28,15 @@ export class AuthManager {
* Opens Pop up window to SAS Login screen.
* And checks if user has finished login process.
*/
public async redirectedLogIn() {
public async redirectedLogIn({ onLoggedOut }: LoginOptions) {
const loginPopup = await openWebPage(
this.loginPreventRedirectUrl,
'SASLogon',
{ width: 500, height: 600 }
{
width: 500,
height: 600
},
onLoggedOut
)
if (!loginPopup) {

View File

@@ -8,7 +8,8 @@ interface windowFeatures {
export async function openWebPage(
url: string,
windowName: string = '',
{ width, height }: windowFeatures
{ width, height }: windowFeatures,
onLoggedOut?: Function
): Promise<Window | null> {
const left = screen.width / 2 - width / 2
const top = screen.height / 2 - height / 2
@@ -20,6 +21,11 @@ export async function openWebPage(
)
if (!loginPopup) {
if (onLoggedOut) {
onLoggedOut()
return null
}
const doLogin = await openLoginPrompt()
return doLogin
? window.open(