func checkLoginStatus(repo *model.Repo) func() {
	log.Debug("checkLoginStatus\n")
	defer log.Debug("return from checkLoginStatus\n")
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		defer cancel()
		var wg sync.WaitGroup
		wg.Add(1)
		js.Global.Get("facebookConnectPlugin").Call("getLoginStatus", func(response *js.Object) {
			go func() {
				defer wg.Done()
				provider := "facebook"
				if authResponse := response.Get("authResponse"); authResponse != js.Undefined {
					token := authResponse.Get("accessToken").String()
					fmt.Printf("token = %s\n", token)
					if err := repo.Auth(context.TODO(), provider, token); err != nil {
						log.Printf("(cls) Auth error: %s", err)
						return
					}
				}
			}()
		}, func() {
			wg.Done()
		})
		wg.Wait()
		if _, err := repo.CurrentUser(); err != nil {
			log.Debugf("(cls) repo err: %s", err)
			return
		}
		if e := checkCtx(ctx); e != nil {
			log.Debugf("(cls) ctx err: %s", e)
			return
		}

		log.Debugln("(cls) Already authenticated")
		js.Global.Get("jQuery").Get("mobile").Call("changePage", "index.html")
	}()
	return cancel
}
// checkLoginStatus checks for auth in the background
checkLoginStatus checks for auth in the background
// checkLoginStatus checks for auth in the background
func checkLoginStatus(repo *model.Repo) func() {
	log.Debug("checkLoginStatus\n")
	defer log.Debug("return from checkLoginStatus\n")
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		defer cancel()
		var wg sync.WaitGroup
		wg.Add(1)
		js.Global.Get("facebookConnectPlugin").Call("getLoginStatus", func(response *js.Object) {
			go func() {
				defer wg.Done()
				provider := "facebook"
				if authResponse := response.Get("authResponse"); authResponse != js.Undefined {
					token := authResponse.Get("accessToken").String()
					fmt.Printf("token = %s\n", token)
					if err := repo.Auth(context.TODO(), provider, token); err != nil {
						log.Printf("(cls) Auth error: %s", err)
						return
					}
				}
			}()
		}, func() {
			wg.Done()
		})
		wg.Wait()
		if _, err := repo.CurrentUser(); err != nil {
			log.Debugf("(cls) repo err: %s", err)
			return
		}
		if e := checkCtx(ctx); e != nil {
			log.Debugf("(cls) ctx err: %s", e)
			return
		}
		log.Debugln("(cls) Already authenticated")
		js.Global.Get("jQuery").Get("mobile").Call("changePage", "index.html")
	}()
	return cancel
}
func checkLoginStatus ( repo * model . Repo ) func ( ) { log . Debug ( " \n " ) defer log . Debug ( " \n " ) ctx , cancel := context . WithCancel ( context . Background ( ) ) go func ( ) { defer cancel ( ) var wg sync . WaitGroup wg . Add ( 1 ) js . Global . Get ( " " ) . Call ( " " , func ( response * js . Object ) { go func ( ) { defer wg . Done ( ) provider := " " if authResponse := response . Get ( " " ) ; authResponse != js . Undefined { token := authResponse . Get ( " " ) . String ( ) fmt . Printf ( " \n " , token ) if err := repo . Auth ( context . TODO ( ) , provider , token ) ; err != nil { log . Printf ( " " , err ) return } } } ( ) } , func ( ) { wg . Done ( ) } ) wg . Wait ( ) if _ , err := repo . CurrentUser ( ) ; err != nil { log . Debugf ( " " , err ) return } if e := checkCtx ( ctx ) ; e != nil { log . Debugf ( " " , e ) return } log . Debugln ( " " ) js . Global . Get ( " " ) . Get ( " " ) . Call ( " " , " " ) } ( ) return cancel }
checkLoginStatus checks for auth in the background
checkLoginStatus checks for auth in the background