summaryrefslogtreecommitdiff
path: root/pkg/backend/api.go
diff options
context:
space:
mode:
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()
}
}