From 9882dfc474e410b5745388ca7d1bbc873be836b3 Mon Sep 17 00:00:00 2001
From: "kali kaneko (leap communications)" <kali@leap.se>
Date: Wed, 19 Aug 2020 17:51:34 +0200
Subject: [PATCH] [bug] anon needs no credentials

---
 gui/qml/main.qml              | 2 +-
 pkg/backend/api.go            | 8 +++-----
 pkg/vpn/bonafide/auth_anon.go | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index f22bdf36..fe69a3bc 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -24,7 +24,7 @@ ApplicationWindow {
                 console.debug(jsonModel.getJson())
                 login.visible = true
             }
-            if (ctx.loginOk == 'true' && loginDone == false) {
+            if (ctx.loginOk == 'true') {
                 loginOk.visible = true
             }
             if (ctx.errors ) {
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index 6609b1b7..7c049fc2 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -17,7 +17,7 @@ func Login(username, password string) {
 	success, err := ctx.bm.DoLogin(username, password)
 	if err != nil {
 		log.Printf("Error on login: %v", err)
-		ctx.Errors = "bad_auth_unknown"
+		ctx.Errors = "bad_auth"
 	} else if success {
 		log.Printf("Logged in as %s", username)
 		ctx.LoginOk = true
@@ -73,13 +73,11 @@ func InitializeBitmaskContext(opts *InitOpts) {
 	opts.AppName = p.AppName
 
 	initOnce.Do(func() { initializeContext(opts) })
-	runDonationReminder()
 	if ctx.bm != nil {
-		if ctx.bm.NeedsCredentials() {
-			ctx.LoginDialog = true
-		}
+		ctx.LoginDialog = ctx.bm.NeedsCredentials()
 		go ctx.updateStatus()
 	}
+	runDonationReminder()
 }
 
 func RefreshContext() *C.char {
diff --git a/pkg/vpn/bonafide/auth_anon.go b/pkg/vpn/bonafide/auth_anon.go
index c6c5775a..9fc95870 100644
--- a/pkg/vpn/bonafide/auth_anon.go
+++ b/pkg/vpn/bonafide/auth_anon.go
@@ -22,7 +22,7 @@ import (
 type anonymousAuthentication struct{}
 
 func (a *anonymousAuthentication) needsCredentials() bool {
-	return true
+	return false
 }
 
 func (a *anonymousAuthentication) getToken(user, password string) ([]byte, error) {
-- 
GitLab