func BTCallback(repo *model.Repo, providers map[string]string) jqeventrouter.HandlerFunc {
	devLoginHandler := devLogin(repo)
	return func(event *jquery.Event, ui *js.Object, params url.Values) bool {
		if params.Get("provider") == "devlogin" {
			log.Debug("Callback for dev login")
			return devLoginHandler(event, ui, params)
		}
		log.Debug("Auth Callback")
		provider, token, err := extractAuthToken(js.Global.Get("location").String())
		if err != nil {
			displayError(err.Error())
			return true
		}
		go func() {
			if err := repo.Auth(context.TODO(), provider, token); err != nil {
				msg := err.Error()
				if strings.Contains(msg, "Session has expired on") {
					for name, href := range providers {
						if name == provider {
							log.Debugf("Redirecting unauthenticated user to %s\n", href)
							js.Global.Get("location").Call("replace", href)
							event.StopImmediatePropagation()
							return
						}
					}
				}
				displayError(msg)
				return
			}
			fmt.Printf("Auth succeeded!\n")
			ui.Set("toPage", "index.html")
			event.StopImmediatePropagation()
			js.Global.Get("jQuery").Get("mobile").Call("changePage", "index.html")
		}()
		return true
	}
}
// BTCallback handles web logins.
BTCallback handles web logins.
// BTCallback handles web logins .
func BTCallback(repo *model.Repo, providers map[string]string) jqeventrouter.HandlerFunc {
	devLoginHandler := devLogin(repo)
	return func(event *jquery.Event, ui *js.Object, params url.Values) bool {
		if params.Get("provider") == "devlogin" {
			log.Debug("Callback for dev login")
			return devLoginHandler(event, ui, params)
		}
		log.Debug("Auth Callback")
		provider, token, err := extractAuthToken(js.Global.Get("location").String())
		if err != nil {
			displayError(err.Error())
			return true
		}
		go func() {
			if err := repo.Auth(context.TODO(), provider, token); err != nil {
				msg := err.Error()
				if strings.Contains(msg, "Session has expired on") {
					for name, href := range providers {
						if name == provider {
							log.Debugf("Redirecting unauthenticated user to %s\n", href)
							js.Global.Get("location").Call("replace", href)
							event.StopImmediatePropagation()
							return
						}
					}
				}
				displayError(msg)
				return
			}
			fmt.Printf("Auth succeeded!\n")
			ui.Set("toPage", "index.html")
			event.StopImmediatePropagation()
			js.Global.Get("jQuery").Get("mobile").Call("changePage", "index.html")
		}()
		return true
	}
}
func BTCallback ( repo * model . Repo , providers map [ string ] string ) jqeventrouter . HandlerFunc { devLoginHandler := devLogin ( repo ) return func ( event * jquery . Event , ui * js . Object , params url . Values ) bool { if params . Get ( " " ) == " " { log . Debug ( " " ) return devLoginHandler ( event , ui , params ) } log . Debug ( " " ) provider , token , err := extractAuthToken ( js . Global . Get ( " " ) . String ( ) ) if err != nil { displayError ( err . Error ( ) ) return true } go func ( ) { if err := repo . Auth ( context . TODO ( ) , provider , token ) ; err != nil { msg := err . Error ( ) if strings . Contains ( msg , " " ) { for name , href := range providers { if name == provider { log . Debugf ( " \n " , href ) js . Global . Get ( " " ) . Call ( " " , href ) event . StopImmediatePropagation ( ) return } } } displayError ( msg ) return } fmt . Printf ( " \n " ) ui . Set ( " " , " " ) event . StopImmediatePropagation ( ) js . Global . Get ( " " ) . Get ( " " ) . Call ( " " , " " ) } ( ) return true } }
BTCallback handles web logins.
BTCallback handles web logins .