login-{validator,app}: Check if the user is already logged elsewhere
This commit is contained in:
parent
f5bac225f0
commit
c313debfdc
4 changed files with 93 additions and 12 deletions
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
|
@ -26,18 +27,25 @@ func modal(p tview.Primitive, width, height int) tview.Primitive {
|
|||
}
|
||||
|
||||
func askLogin(app *tview.Application) {
|
||||
CreateLoginDialog(app, func(username, password string) {
|
||||
var afterLogin func(username, password string, force *bool)
|
||||
afterLogin = func(username, password string, force *bool) {
|
||||
// Display check dialog
|
||||
CreateCheckDialog(app)
|
||||
|
||||
go func() {
|
||||
if ok, err := checkLogin(username, password); ok {
|
||||
if status, err := checkLogin(username, password, force); status == http.StatusOK {
|
||||
loggedAs = username
|
||||
app.Stop()
|
||||
} else if status == http.StatusPaymentRequired {
|
||||
CreateForceLoginDialog(app, username, password, afterLogin)
|
||||
} else {
|
||||
CreateErrMsgDialog(app, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
CreateLoginDialog(app, func(username, password string) {
|
||||
afterLogin(username, password, nil)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue