Lock.swift icon indicating copy to clipboard operation
Lock.swift copied to clipboard

Generic error message when using api.access.deny in login action

Open mmuelder opened this issue 5 years ago • 4 comments

Describe the problem

Greetings!

When returning an error message via a Login-Action, we get a generic error message, instead of the one returned in the action. 0d1266cd39cb46018c43622d2b8c3c5c3a2836c4

What was the expected behavior?

Display of the custom error message returned in the action.

Reproduction

We previously had a Rule that checks if a user is verified. If not, we returned return callback(new UnauthorizedError('our custom error message')); This worked just fine. We got ‘our custom error message’.

Now we wanted to switch to Actions. Inside the action we return the error like this: api.access.deny('our custom error message');

But instead of our error message, the login shows the generic error, as seen in the screenshot. We also have a web app and an Android app where the correct custom error message is shown and everything works fine. The problem only occurs with this iOS SDK.

What can we do, to display the error passed by api.access.deny() to the user? In the logs everything looks fine, the error description is ‘our custom error message’.

Log entry with rule (custom error message is shown in the ui)

{
  "date": "2021-11-18T11:40:48.539Z",
  "type": "fepft",
  "description": "our custom error message",
  "connection": "our-app",
  "connection_id": "con_cFDGZAaA7Lb0AGb8",
  "client_id": "j5jT3gWIopJDGQJvSK00Rbwg1KmBYpbD",
  "client_name": "Our App Name",
  "ip": "my ip",
  "client_ip": "my ip",
  "user_agent": "Our App Name 1.0.0 / Other 0.0.0",
  "hostname": "auth.our.domain",
  "user_id": "",
  "user_name": "[email protected]",
  "audience": "https://our.domain/Service/",
  "scope": "openid email offline_access",
  "auth0_client": {
    "env": {
      "core": "1.37.1",
      "swift": "5.x",
      "iOS": "12.5"
    },
    "name": "Lock.swift",
    "version": "2.24.0"
  },
  "log_id": "90020211118114053634098613202136367420228063293318627410",
  "_id": "90020211118114053634098613202136367420228063293318627410",
  "isMobile": false
}

Log entry with action (wrong, generic error message is shown in the ui)

{
  "date": "2021-11-18T11:34:00.745Z",
  "type": "fepft",
  "description": "our custom error message",
  "connection": "our-app",
  "connection_id": "con_cFDGZAaA7Lb0AGb8",
  "client_id": "j5jT3gWIopJDGQJvSK00Rbwg1KmBYpbD",
  "client_name": "Our App Name",
  "ip": "my ip",
  "client_ip": "my ip",
  "user_agent": Our App Name 1.0.0 / Other 0.0.0",
  "details": {
    "actions": {
      "executions": [
        "BkPFW1H6RQGuJH1McFq3RzIwMjExMTE4"
      ]
    }
  },
  "hostname": "auth.our.domain",
  "user_id": "",
  "user_name": "[email protected]",
  "audience": "https://our.domain/Service/",
  "scope": "openid email offline_access",
  "auth0_client": {
    "env": {
      "core": "1.37.1",
      "swift": "5.x",
      "iOS": "12.5"
    },
    "name": "Lock.swift",
    "version": "2.24.0"
  },
  "log_id": "90020211118113403184353413272563954882875995236864098354",
  "_id": "90020211118113403184353413272563954882875995236864098354",
  "isMobile": false
}

In both cases the custom error message is set in the description. Why do we see our custom message in the first case and the generic error in the second in the acutal ui? The only visible difference in the logs is the added "details" attribute when using the action

Thanks Marius

Environment

  • **Version of lock.swift: 2.24.0
  • **Version of iOS/macOS/tvOS/watchOS: any we tried

mmuelder avatar Nov 18 '21 12:11 mmuelder

Hi @mmuelder, thanks for raising this.

We also have a web app and an Android app where the correct custom error message is shown and everything works fine.

The current major of Lock.Android (v3) does not display the Action error message in the UI, returning it instead via a callback for the developer to handle:

https://user-images.githubusercontent.com/5055789/145688676-8cb94fc0-a687-4d2f-8e8d-79a09ece0e31.mov

The previous major of Lock.Android (v2) displays in the UI a generic error message, not the Action error message:

https://user-images.githubusercontent.com/5055789/145688704-6d6b407a-a5cf-46f2-8beb-ec3ffc4adc5e.mov

The current major version of Lock.swift would correspond to the behavior of Lock.Android v2. Given that this is not a matter of feature parity between Lock.swift and Lock.Android v2, we'll be closing this issue as they are both behaving the same WRT to Action error messages.

Widcket avatar Dec 11 '21 19:12 Widcket

Thanks for looking into this!

The current major of Lock.Android (v3) does not display the Action error message in the UI, returning it instead via a callback for the developer to handle:

Thats true, we read it from the callback and display it to the user.

My question is, is this possible for iOS? How can we access "our custom error message" in the iOS SDK to display it to the user? Is there any documentary for displaying an error message to the user that was created by an action?

mmuelder avatar Dec 13 '21 07:12 mmuelder

@mmuelder the current major of Lock.swift does not expose the error message to the developer. And adding that would be a behavior breaking change. So you could fork Lock.swift and incorporate the changes from https://github.com/auth0/Lock.swift/pull/693. We cannot match the behavior of the current major of Lock.Android without a new major of Lock.swift.

Widcket avatar Dec 14 '21 00:12 Widcket

@Widcket so in other words: If we return a custom error message from an action, there is no way to display this message to the user with the current version of Lock.swift? That sounds a bit strange, since Auth0 recommends swichting from rules to actions. And rules offer this possibility which is necessary for many use cases. This would mean that we cannot switch from our rule to an action even if we would like to. :(

mmuelder avatar Dec 14 '21 11:12 mmuelder