Skip to content

Commit

Permalink
legacyprovision: fix cookies and API path
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpShell committed Oct 28, 2024
1 parent d0447a9 commit 0cb2b0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cmd/mautrix-twitter/legacyprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ type Response struct {
func legacyProvLogin(w http.ResponseWriter, r *http.Request) {
user := m.Matrix.Provisioning.GetUser(r)
ctx := r.Context()
var newCookies map[string]string
err := json.NewDecoder(r.Body).Decode(&newCookies)
var cookies map[string]string
err := json.NewDecoder(r.Body).Decode(&cookies)
if err != nil {
jsonResponse(w, http.StatusBadRequest, Error{ErrCode: mautrix.MBadJSON.ErrCode, Error: err.Error()})
return
}

newCookies := map[string]string{
"auth_token": cookies["auth_token"],
"ct0": cookies["csrf_token"],
}

lp, err := c.CreateLogin(ctx, user, "cookies")
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to create login")
Expand Down
4 changes: 2 additions & 2 deletions cmd/mautrix-twitter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func main() {
}
m.PostStart = func() {
if m.Matrix.Provisioning != nil {
m.Matrix.Provisioning.Router.HandleFunc("/v1/login", legacyProvLogin).Methods(http.MethodGet)
m.Matrix.Provisioning.Router.HandleFunc("/v1/logout", legacyProvLogout).Methods(http.MethodPost)
m.Matrix.Provisioning.Router.HandleFunc("/api/login", legacyProvLogin).Methods(http.MethodGet)
m.Matrix.Provisioning.Router.HandleFunc("/api/logout", legacyProvLogout).Methods(http.MethodPost)
}
}

Expand Down

0 comments on commit 0cb2b0b

Please sign in to comment.