fix(oauth): authorised client error on fresh sessions #32

merged
opened by brookjeynes.dev targeting master from push-rozvknvsxslu

During the callback phase of oauth, we check to see if a user account exists in the pds and if not, create one. This requires an authorised client. This fixes an issue where the client authorised client wasn't grabbed successfully out of the session.

Signed-off-by: brookjeynes me@brookjeynes.dev

Changed files
+3 -1
internal
server
oauth
+3 -1
internal/server/oauth/handler.go
···
return
}
-
client, err := o.AuthorizedClient(r)
+
clientSession, err := o.ClientApp.ResumeSession(r.Context(), sessData.AccountDID, sessData.SessionID)
if err != nil {
l.Error("failed to get authorized client", "err", err)
http.Redirect(w, r, "/login?error=client", http.StatusFound)
return
}
+
client := clientSession.APIClient()
+
ex, _ := comatproto.RepoGetRecord(r.Context(), client, "", yoten.ActorProfileNSID, did, "self")
var cid *string
if ex != nil {