Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Stub Logout API
Browse files Browse the repository at this point in the history
  • Loading branch information
smweber committed Sep 20, 2023
1 parent 32d0226 commit e8ee765
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (prov *ProvisioningAPI) Init() {
r.HandleFunc("/v2/link/new", prov.LinkNew).Methods(http.MethodPost)
r.HandleFunc("/v2/link/wait/scan", prov.LinkWaitForScan).Methods(http.MethodPost)
r.HandleFunc("/v2/link/wait/account", prov.LinkWaitForAccount).Methods(http.MethodPost)
r.HandleFunc("/v2/logout", prov.Logout).Methods(http.MethodPost)
}

type responseWrap struct {
Expand Down Expand Up @@ -303,3 +304,28 @@ func (prov *ProvisioningAPI) LinkWaitForAccount(w http.ResponseWriter, r *http.R
return
}
}

func (prov *ProvisioningAPI) Logout(w http.ResponseWriter, r *http.Request) {
//user := r.Context().Value("user").(*User)
body := struct {
SessionID string `json:"session_id"`
DeviceName string `json:"device_name"`
}{}
err := json.NewDecoder(r.Body).Decode(&body)
if err != nil {
prov.log.Err(err).Msg("Error decoding JSON body")
jsonResponse(w, http.StatusBadRequest, Error{
Success: false,
Error: "Error decoding JSON body",
ErrCode: "M_BAD_JSON",
})
return
}
// For now do nothing - we need this API to return 200 to be compatible with
// the old Signal bridge, which needed a call to Logout before allowing LinkNew
// to be called, but we don't actually want to logout, we want to allow a reconnect.
jsonResponse(w, http.StatusOK, Response{
Success: true,
Status: "logged_out",
})
}

0 comments on commit e8ee765

Please sign in to comment.