@@ -89,9 +89,9 @@ function Authing(opts) {
8989 self . ownerAuth . authSuccess = false ;
9090 throw `认证失败: ${ error . message . message || error } ` ;
9191 } ) ;
92- } else {
93- this . checkPreflight ( ) ;
9492 }
93+
94+ this . checkPreflight ( ) ;
9595}
9696
9797Authing . prototype = {
@@ -1011,7 +1011,7 @@ Authing.prototype = {
10111011 * @param {Boolean } params.useGuard 是否使用 Guard
10121012 */
10131013 readOAuthList ( params ) {
1014- if ( ! params || typeof params !== 'object' ) {
1014+ if ( ! params || typeof params !== 'object' ) {
10151015 return this . _readOAuthList ( )
10161016 . then ( ( list ) => {
10171017 if ( list ) {
@@ -1021,18 +1021,17 @@ Authing.prototype = {
10211021 message : '获取OAuth列表失败,原因未知'
10221022 } ;
10231023 } ) ;
1024- } else {
1025- return this . _readOAuthList ( params )
1026- . then ( ( list ) => {
1027- if ( list ) {
1028- return list . filter ( item => item . enabled ) ;
1029- }
1030- throw {
1031- message : '获取OAuth列表失败,原因未知'
1032- } ;
1033- } ) ;
10341024 }
10351025
1026+ return this . _readOAuthList ( params )
1027+ . then ( ( list ) => {
1028+ if ( list ) {
1029+ return list . filter ( item => item . enabled ) ;
1030+ }
1031+ throw {
1032+ message : '获取OAuth列表失败,原因未知'
1033+ } ;
1034+ } ) ;
10361035 } ,
10371036
10381037 sendResetPasswordEmail ( options ) {
@@ -1370,8 +1369,9 @@ Authing.prototype = {
13701369
13711370 genQRCode ( clientId ) {
13721371 const random = this . randomWord ( true , 12 , 24 ) ;
1373- if ( typeof sessionStorage !== 'undefined' )
1372+ if ( typeof sessionStorage !== 'undefined' ) {
13741373 sessionStorage . randomWord = random ;
1374+ }
13751375
13761376 let url = configs . services . oauth . host ;
13771377 url = url . replace ( '/graphql' , '' ) ;
@@ -1396,7 +1396,7 @@ Authing.prototype = {
13961396
13971397 const mountNode = opts . mount || 'authing__qrcode-root-node' ;
13981398 const interval = opts . interval || 1500 ;
1399- const { tips } = opts ;
1399+ const { tips, successTips , successRedirectTips , retryTips , failedTips } = opts ;
14001400
14011401 let redirect = true ;
14021402
@@ -1500,7 +1500,7 @@ Authing.prototype = {
15001500 unloading ( ) ;
15011501 } ;
15021502
1503- const shadow = genShadow ( '点击重试' , ( ) => {
1503+ const shadow = genShadow ( retryTips || '点击重试' , ( ) => {
15041504 start ( ) ;
15051505 } ) ;
15061506
@@ -1524,7 +1524,7 @@ Authing.prototype = {
15241524 const qrcode = qrRes . data ;
15251525 if ( onQRCodeLoad ) {
15261526 onQRCodeLoad ( qrcode ) ;
1527- }
1527+ }
15281528 sessionStorage . qrcodeUrl = qrcode . qrcode ;
15291529 sessionStorage . qrcode = JSON . stringify ( qrcode ) ;
15301530
@@ -1550,15 +1550,15 @@ Authing.prototype = {
15501550 if ( checkResult . code === 200 ) {
15511551 clearInterval ( inter ) ;
15521552 if ( redirect ) {
1553- const shadowX = genShadow ( '扫码成功,即将跳转' , ( ) => {
1553+ const shadowX = genShadow ( successRedirectTips || '扫码成功,即将跳转' , ( ) => {
15541554 window . location . href = `${ checkResult . redirect } ?code=200&data=${ JSON . stringify ( checkResult . data ) } ` ;
15551555 } ) ;
15561556 setTimeout ( ( ) => {
15571557 window . location . href = `${ checkResult . redirect } ?code=200&data=${ JSON . stringify ( checkResult . data ) } ` ;
15581558 } , 600 ) ;
15591559 qrcodeWrapper . appendChild ( shadowX ) ;
15601560 } else {
1561- const shadow = genShadow ( '扫码成功' ) ;
1561+ const shadow = genShadow ( successTips || '扫码成功' ) ;
15621562 qrcodeWrapper . appendChild ( shadow ) ;
15631563 if ( onSuccess ) {
15641564 onSuccess ( checkResult ) ;
@@ -1577,7 +1577,7 @@ Authing.prototype = {
15771577 }
15781578 }
15791579 } ) . catch ( ( error ) => {
1580- genRetry ( qrcodeNode , '网络出错,请重试' ) ;
1580+ genRetry ( qrcodeNode , failedTips || '网络出错,请重试' ) ;
15811581 if ( onError ) {
15821582 onError ( error ) ;
15831583 }
0 commit comments