summaryrefslogtreecommitdiff
path: root/pkg/backend/api.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2020-08-06 13:01:22 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-20 20:27:44 +0200
commit60a35bdde41e8648594dc6a501a11000081ff878 (patch)
tree20336cb66893e265c9125f66dc3e942ff8e1c467 /pkg/backend/api.go
parent249a8844b1aaf2cd2bf6fddc8da10a4defb656d2 (diff)
[pkg] add float-deployed demo libpvn for tests
Diffstat (limited to 'pkg/backend/api.go')
-rw-r--r--pkg/backend/api.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index ff8c1bb..7b48906 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -13,6 +13,21 @@ import (
"0xacab.org/leap/bitmask-vpn/pkg/pickle"
)
+func Login(username, password string) {
+ success, err := ctx.bm.DoLogin(username, password)
+ if err != nil {
+ // TODO
+ log.Printf("Error login: %v", err)
+ } else if success {
+ // TODO: Notify success
+ log.Printf("Logged in as %s", username)
+ } else {
+ // TODO: display login again with an err
+ log.Printf("Failed to login as %s", username)
+ ctx.LoginDialog = true
+ }
+}
+
func SwitchOn() {
go setStatus(starting)
go startVPN()
@@ -57,6 +72,9 @@ func InitializeBitmaskContext(opts *InitOpts) {
initOnce.Do(func() { initializeContext(opts) })
runDonationReminder()
if ctx.bm != nil {
+ if ctx.bm.NeedsCredentials() {
+ ctx.LoginDialog = true
+ }
go ctx.updateStatus()
}
}