updated /api/oauth2-redirect error messages

This commit is contained in:
Gani Georgiev
2023-04-25 11:52:56 +03:00
parent 0b5e189563
commit 0478f84867
3 changed files with 21 additions and 10 deletions
+6 -2
View File
@@ -642,9 +642,13 @@ func (api *recordAuthApi) oauth2SubscriptionRedirect(c echo.Context) error {
state := c.QueryParam("state")
code := c.QueryParam("code")
if code == "" || state == "" {
return NewBadRequestError("Invalid OAuth2 redirect parameters.", nil)
}
client, err := api.app.SubscriptionsBroker().ClientById(state)
if err != nil || client.IsDiscarded() || !client.HasSubscription(oauth2SubscriptionTopic) {
return NewNotFoundError("Missing or invalid oauth2 subscription client", err)
return NewNotFoundError("Missing or invalid OAuth2 subscription client.", err)
}
data := map[string]string{
@@ -654,7 +658,7 @@ func (api *recordAuthApi) oauth2SubscriptionRedirect(c echo.Context) error {
encodedData, err := json.Marshal(data)
if err != nil {
return NewBadRequestError("Failed to marshalize oauth2 redirect data", err)
return NewBadRequestError("Failed to marshalize OAuth2 redirect data.", err)
}
msg := subscriptions.Message{