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

Return SSO error as object #126

Closed
rijkvanzanten opened this issue May 11, 2018 · 13 comments
Closed

Return SSO error as object #126

rijkvanzanten opened this issue May 11, 2018 · 13 comments
Labels
enhancement New feature or request

Comments

@rijkvanzanten
Copy link
Member

Right now, an invalid login is returned as an (English) string:
http://localhost:8080/login?error=User%20with%20email%20%22rijkvanzanten%40me.com%22%20not%20found

With i18n in mind, there is no way to accurately translate this right now.

It would be perfect if the API would return

{
  "error": {
    "code": 111,
    "email": "rijkvanzanten@me.com"
  }
}

that way, the app can map 111 to the string User with email "${email}" not found.

@rijkvanzanten rijkvanzanten added the enhancement New feature or request label May 11, 2018
@wellingguzman
Copy link
Contributor

Using the error code won't make it useful in this case at least? you already have the email you use to make the request.

@rijkvanzanten
Copy link
Member Author

The app doesn't have anything. It's like someone opening the page fresh. The only info the app has is the info you provide it in the query parameters 🙂

@wellingguzman
Copy link
Contributor

wellingguzman commented May 11, 2018

Ah you are right! Would this work:

{
  "error": {
    "code": 111,
    "attributes": {
      "email": "rijkvanzanten@me.com"
    }
  }
}

That way we can add more attributes for future errors.

@rijkvanzanten
Copy link
Member Author

Yep, looks good!

We could maybe drop the error nested key to save some bytes. We already know it's an error seeing it's in the error query parameter!

{
    "code": 111,
    "attributes": {
      "email": "rijkvanzanten@me.com"
    }
}

@wellingguzman
Copy link
Contributor

oh wait, These are passed through query strings, so it will ended up: error=message&code=111&attributes[email]=rijkvanzanten@me.com or maybe change code to errorCode?

@rijkvanzanten
Copy link
Member Author

Can't we pass it as a JSON string in the parameter?

?error={"code":111,"attributes":{"email":"rijkvanzanten@me.com"}}

@wellingguzman
Copy link
Contributor

I can, I was trying not to use json. I will update to fit your needs.

One more question does the original error message will be gone or be inside with the message key?

@rijkvanzanten
Copy link
Member Author

Ehh IMO we can get rid of it. The actual error translations will live in the application. As long as we have the code (and the docs that say what code means what), we're solid.

I can, I was trying not to use json.

I get what you're saying..

We could also move to ?error=true&code=111&attributes[email]=rijkvanzanten@me.com if you prefer that 🙂

@wellingguzman
Copy link
Contributor

Okay, I will change it to ?error=true&code=111&attributes[email]=rijkvanzanten@me.com

@wellingguzman
Copy link
Contributor

One thing error=true will be changed to error=true, because true (boolean) will be converted to 1.

wellingguzman added a commit that referenced this issue May 11, 2018
@rijkvanzanten
Copy link
Member Author

One thing error=true will be changed to error=true

wat

@wellingguzman
Copy link
Contributor

Hahaha, I am out.

error=true will be changed to error=1

@wellingguzman
Copy link
Contributor

Already implemented as ?error=true&code=111&attributes[email]=rijkvanzanten@me.com

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants