Skip to content

Commit

Permalink
Add MemberEventMessages error codes to all filters
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-e committed Nov 1, 2017
1 parent 0e376e1 commit 02aac90
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
20 changes: 15 additions & 5 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,21 @@ public function checkEventPermissions(array &$context){
$success = $role->canProcessEvent($event_handle, $action, $required_level) ? true : false;
}

$context['messages'][] = array(
'permission',
$success,
($success === false) ? __('You are not authorised to perform this action.') : null
);
if ($success === true) {
$context['messages'][] = array(
'permission',
true
);
} else {
$context['messages'][] = array(
'permission',
false,
__('You are not authorised to perform this action.'),
array(
'message-id' => MemberEventMessages::UNAUTHORIZED
)
);
}

// Process the Filters for this event.
$this->__processEventFilters($context);
Expand Down
2 changes: 2 additions & 0 deletions lib/class.membersevent.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ class MemberEventMessages extends EventMessages
{
const MEMBER_ERRORS = 104;
const MEMBER_INVALID = 105;
const UNAUTHORIZED = 106;

const SECTION_INVALID = 201;

const ACTIVATION_PRE_COMPLETED = 303;
const ACTIVATION_CODE_INVALID = 304;
const RECOVERY_CODE_INVALID = 305;
const AUTHENTICATION_INVALID = 306;

const ALREADY_LOGGED_IN = 501;
}
15 changes: 12 additions & 3 deletions lib/member.symphony.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ public function filter_ValidatePassword(array &$context) {
$context['messages'][] = array(
'member-validate-password',
false,
__('Member not found.')
__('Member not found.'),
array(
'message-id' => MemberEventMessages::MEMBER_INVALID
)
);

return;
Expand All @@ -396,7 +399,10 @@ public function filter_ValidatePassword(array &$context) {
$context['messages'][] = array(
'member-validate-password',
false,
__('No Authentication field found.')
__('No Authentication field found.'),
array(
'message-id' => MemberEventMessages::MEMBER_ERRORS
)
);

return;
Expand Down Expand Up @@ -431,7 +437,10 @@ public function filter_ValidatePassword(array &$context) {
$context['messages'][] = array(
'member-validate-password',
false,
__('No valid password has been provided.')
__('No valid password has been provided.'),
array(
'message-id' => MemberEventMessages::AUTHENTICATION_INVALID
)
);
}
}
Expand Down

0 comments on commit 02aac90

Please sign in to comment.