Authorization and Jquery dialog problem.
Posted
by bbrepols
on Stack Overflow
See other posts from Stack Overflow
or by bbrepols
Published on 2010-03-26T14:25:17Z
Indexed on
2010/03/31
8:03 UTC
Read the original article
Hit count: 330
Hi,
I have a little problem with a Jquery dialog for an action that requires a role. In my example, the user can click on a delete button and must confirm the action. In my controller, the Delete action requires a role, if the user is in the required role, the object is deleted.
The problem: How to alert the user if * the element was deleted (redirect to the Index view) * there was an error (alert with the message) * he doesn't have the rights to delete (alert with the message)
Before using the authorize filter, the delete action returned a JSON with a Boolean that indicates if there was an error, an URL to redirect on success and a message to alert on error.
As I can't return a JSON from my filter, I created an other method with the authorize filter that returns a partial view with the confirm content. If the user doesn't have the rights, the filter returns a partial view with an unauthorized exception content.
The problem: How to distinct which partial view was returned. When I create the dialog, I need to know for the buttons function.
Thanks!
© Stack Overflow or respective owner