u
Anirudh Oppiliappan x@icyphox.sh
Tue, 26 Sep 2023 19:52:30 +0300
3 files changed,
24 insertions(+),
4 deletions(-)
M
masto.go
→
masto.go
@@ -7,7 +7,24 @@ "net/http"
"time" "humungus.tedunangst.com/r/webs/junk" + "humungus.tedunangst.com/r/webs/login" ) + +type NotResponseWriter struct { + body []byte + header http.Header +} + +func (w NotResponseWriter) Header() http.Header { + return w.header +} + +func (w NotResponseWriter) Write(b []byte) (int, error) { + w.body = b + return 0, nil +} + +func (w NotResponseWriter) WriteHeader(statusCode int) {} func snowflake() uint64 { ts := time.Now()@@ -76,7 +93,11 @@ }
// https://docs.joinmastodon.org/methods/oauth/#authorize func oauthorize(rw http.ResponseWriter, r *http.Request) { - http.Redirect(rw, r, "/login", 302) + var nrw NotResponseWriter + login.LoginFunc(nrw, r) + dlog.Println("got code!", string(nrw.body)) + rw.WriteHeader(http.StatusOK) + return } // https://docs.joinmastodon.org/methods/instance/#v2
M
views/oauthlogin.html
→
views/oauthlogin.html
@@ -2,7 +2,7 @@ {{ template "header.html" . }}
<main> <div class="info"> <h3>honk oauthorize</h3> -<form action="/dologin" method="POST"> +<form action="/oauth/authorize" method="POST"> <p><input tabindex=1 type="text" name="username" autocomplete=off> - username <p><input tabindex=1 type="password" name="password"> - password <input type="hidden" name="gettoken" value="1" />
M
web.go
→
web.go
@@ -2986,10 +2986,9 @@
// mastoshit mastopost := mux.Methods("POST").Subrouter() mastoget := mux.Methods("GET").Subrouter() - mastoget.HandleFunc("/oauth/authorize", showoauthlogin) + mastopost.HandleFunc("/oauth/authorize", oauthorize) mastoget.HandleFunc("/api/v1/instance", instance) - mastopost.HandleFunc("/api/v1/apps", apiapps) err = http.Serve(listener, mux)