mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Fix QR codes not rendering for admin
This commit is contained in:
parent
51dce1876d
commit
3a705cf252
2
todo.md
2
todo.md
@ -1,7 +1,5 @@
|
|||||||
# 31 Oct 2020 Launch List
|
# 31 Oct 2020 Launch List
|
||||||
|
|
||||||
- [ ] Anyone can delete tokens
|
|
||||||
- [ ] QR codes for admin are broken
|
|
||||||
- [ ] General security review.
|
- [ ] General security review.
|
||||||
- [ ] Invalid database is wiping out tunnels
|
- [ ] Invalid database is wiping out tunnels
|
||||||
- [ ] Improve SSH key download UI.
|
- [ ] Improve SSH key download UI.
|
||||||
|
@ -211,7 +211,6 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
|
|||||||
|
|
||||||
var tokens map[string]TokenData
|
var tokens map[string]TokenData
|
||||||
var users map[string]User
|
var users map[string]User
|
||||||
qrCodes := make(map[string]template.URL)
|
|
||||||
|
|
||||||
if user.IsAdmin {
|
if user.IsAdmin {
|
||||||
tokens = h.db.GetTokens()
|
tokens = h.db.GetTokens()
|
||||||
@ -224,24 +223,28 @@ func (h *WebUiHandler) handleWebUiRequest(w http.ResponseWriter, r *http.Request
|
|||||||
tokens[token] = td
|
tokens[token] = td
|
||||||
}
|
}
|
||||||
|
|
||||||
loginUrl := fmt.Sprintf("https://%s/login?access_token=%s", h.config.WebUiDomain, token)
|
|
||||||
|
|
||||||
var png []byte
|
|
||||||
png, err := qrcode.Encode(loginUrl, qrcode.Medium, 256)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteHeader(500)
|
|
||||||
h.alertDialog(w, r, err.Error(), "/#/tokens")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data := base64.StdEncoding.EncodeToString(png)
|
|
||||||
qrCodes[token] = template.URL("data:image/png;base64," + data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
users = make(map[string]User)
|
users = make(map[string]User)
|
||||||
users[tokenData.Owner] = user
|
users[tokenData.Owner] = user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qrCodes := make(map[string]template.URL)
|
||||||
|
for token := range tokens {
|
||||||
|
loginUrl := fmt.Sprintf("https://%s/login?access_token=%s", h.config.WebUiDomain, token)
|
||||||
|
|
||||||
|
var png []byte
|
||||||
|
png, err := qrcode.Encode(loginUrl, qrcode.Medium, 256)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(500)
|
||||||
|
h.alertDialog(w, r, err.Error(), "/#/tokens")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := base64.StdEncoding.EncodeToString(png)
|
||||||
|
qrCodes[token] = template.URL("data:image/png;base64," + data)
|
||||||
|
}
|
||||||
|
|
||||||
indexData := IndexData{
|
indexData := IndexData{
|
||||||
Head: h.headHtml,
|
Head: h.headHtml,
|
||||||
Tunnels: tunnels,
|
Tunnels: tunnels,
|
||||||
|
Loading…
Reference in New Issue
Block a user