I'd like to allow a non-admin user to remove their own account from the front end of my app, without allowing them CP access.
I'm concerned that if I give the user group deleteUser
permissions they will just be able to delete any other non-admin user if they change the values of my forms hidden inputs.
Here is my current form:
<form method="post" accept-charset="UTF-8">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="users/deleteUser">
<input type="hidden" name="redirect" value="account/delete/success">
<input type="hidden" name="userId" value="{{ currentUser.id }}">
<button type="submit" class="btn btn--red">Delete my account!</button>
</form>
Is it best that I create a custom controller action to handle this and first check they are only deleting themselves before passing it off to the craft()->users->deleteUser()
function? Or is there a better way?