ipn/localapi: implement LoginInteractive via localapi

Updates: #4738

Signed-off-by: Joel Cressy <joel@jtcressy.net>
pull/4742/head
Joel Cressy 2 years ago committed by Brad Fitzpatrick
parent 0f95eaa8bb
commit c16271fb46

@ -109,6 +109,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.serveStatus(w, r)
case "/localapi/v0/logout":
h.serveLogout(w, r)
case "/localapi/v0/login-interactive":
h.serveLoginInteractive(w, r)
case "/localapi/v0/prefs":
h.servePrefs(w, r)
case "/localapi/v0/ping":
@ -343,6 +345,20 @@ func (h *Handler) serveStatus(w http.ResponseWriter, r *http.Request) {
e.Encode(st)
}
func (h *Handler) serveLoginInteractive(w http.ResponseWriter, r *http.Request) {
if !h.PermitWrite {
http.Error(w, "login access denied", http.StatusForbidden)
return
}
if r.Method != "POST" {
http.Error(w, "want POST", 400)
return
}
h.b.StartLoginInteractive()
w.WriteHeader(http.StatusNoContent)
return
}
func (h *Handler) serveLogout(w http.ResponseWriter, r *http.Request) {
if !h.PermitWrite {
http.Error(w, "logout access denied", http.StatusForbidden)

Loading…
Cancel
Save