-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogout.go
More file actions
137 lines (105 loc) · 3.33 KB
/
logout.go
File metadata and controls
137 lines (105 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package main
import (
"github.com/deroproject/derohe/globals"
"github.com/deroproject/derohe/rpc"
)
// here is the simple way we log out
func logout() {
logger.Info("logging out")
// update the header
updateHeader(program.hyperlinks.logout)
// if there is a wallet in memory and it saves
if program.wallet != nil {
// and as long as there is an rpc server in memory
if program.rpc_server != nil && globals.Arguments["--rpc-server"] != nil {
// stop the rpc server
program.rpc_server.RPCServer_Stop()
logger.Info("logging out", "rpc", "stopped")
// make it noticable
program.labels.rpc_server.SetText("RPC: 🔴")
// dump the creds
program.entries.username.SetText("")
program.entries.password.SetText("")
// toggle the servers off
program.toggles.rpc_server.SetSelected("off")
// clear the rpc server from memory
program.rpc_server = nil
delete(globals.Arguments, "--rpc-server")
delete(globals.Arguments, "--rpc-login")
delete(globals.Arguments, "--rpc-bind")
}
if program.ws_server != nil {
program.ws_server.Stop()
program.toggles.ws_server.SetSelected("off")
logger.Info("logging out", "ws", "stopped")
}
// close out the wallet
program.wallet.Close_Encrypted_Wallet()
logger.Info("logging out", "wallet", "closed")
program.wallet = nil // completely remove the wallet
// reset the balance
program.labels.balance.SetText("BALANCE: 0")
program.labels.loggedin.SetText("WALLET: 🔴")
// clear the cache
program.caches.assets = []asset{}
program.node.info = rpc.GetInfo_Result{}
program.node.pool = rpc.GetTxPool_Result{}
logger.Info("logging out", "caches", "emptied")
// close windows if any
if program.encryption != nil {
program.encryption.Close()
}
if program.contracts != nil {
program.contracts.Close()
}
if program.explorer != nil {
program.explorer.Close()
}
logger.Info("logging out", "windows", "closed")
}
// there is the off chance that they log out before they are registered
if program.containers.register.Visible() {
// stop and hide the registration activity
program.activities.registration.Stop()
program.activities.registration.Hide()
// hide the label
program.labels.counter.Hide()
// hide the container
program.containers.register.Hide()
// hide the buttons
program.buttons.register.Show()
}
// hide containers
program.containers.dashboard.Hide()
program.containers.send.Hide()
program.containers.toolbox.Hide()
// hide hyperlinks
program.hyperlinks.logout.Hide()
program.hyperlinks.tools.Hide()
program.hyperlinks.lockscreen.Hide()
program.hyperlinks.address.Hide()
program.hyperlinks.generate.Hide()
// hide labels
program.labels.address.Hide()
program.labels.balance.Hide()
// hide buttons
program.buttons.rpc_server.Hide()
program.buttons.ws_server.Hide()
program.buttons.update_password.Hide()
program.buttons.assets.Hide()
program.buttons.balance_rescan.Hide()
// show labels
program.labels.notice.Show()
// show hyperlinks
program.hyperlinks.login.Show()
program.hyperlinks.login.Show()
program.hyperlinks.create.Show()
// update the header
updateHeader(program.hyperlinks.home)
program.window.SetTitle(program.name)
// now we are logged out
program.preferences.SetBool("loggedIn", false)
// show home
setContentAsHome()
logger.Info("logging out", "logout", "complete")
}