Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Ajax Login Validation #2324

Draft
wants to merge 4 commits into
base: 6.dev
Choose a base branch
from

Conversation

mithra62
Copy link
Contributor

Overview

Adds an Action to validate a username and password pair, ideally within an Ajax request prior to login form submission.

Resolves #1993.

Nature of This Change

  • πŸ› Fixes a bug
  • πŸš€ Implements a new feature
  • πŸ› Refactors existing code
  • πŸ’… Fixes coding style
  • βœ… Adds tests
  • πŸ‘½ Adds new dependency
  • πŸ”₯ Removes unused files / code
  • πŸ”’ Improves security

Is this backwards compatible?

  • Yes
  • No

Documentation

User Guide Pull Request: https://github.com/ExpressionEngine/ExpressionEngine-User-Guide/pull/NNN

@mithra62
Copy link
Contributor Author

@intoeetive we'll still need to update the Installer to create the exp_actions row but I'm not sure how best to handle that tbh. Never played with the Installer lol

@mithra62 mithra62 changed the title adds action method Adds Ajax Login Validation Aug 23, 2022
Comment on lines 1617 to 1621
echo json_encode([
'result' => ($verify ? 'success' : 'fail'),
'reason' => $reasons,
'username' => ee()->input->get('username'),
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use ee()->output->send_ajax_response as it sends the correct header and assures there's no profiler present in AJAX response, if it's enabled

Also not real issue, but result => fail is not being used in EE, more common are things 'messageType' => 'error', or 'status' => 'error',. As well as reason - could it be error? Again, this will not create any issues, just trying to keep it more consistent with what we have in other places - let me know if you have specific reason to keep them this way.

I will also make the PR draft until the action record part and the docs are ready

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, no reason whatsoever for it; was just a carry over from previous implementations. What you think of something like this:

        ee()->output->send_ajax_response([
            'messageType' => ($verify ? 'success' : 'error'),
            'errors' => $reasons,
            'username' => ee()->input->get('username'),
        ]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... maybe messages in lieu of errors...

@intoeetive intoeetive marked this pull request as draft August 24, 2022 07:35
@mithra62
Copy link
Contributor Author

I think I found how to do the updater stuff; shoulda realized it was in the Add-on proper. @intoeetive can you poke at the upd.member change? I think I did it right but confidence isn't as high as I'd like.

@@ -80,6 +83,11 @@ public function update($current = '')
ee()->db->update('actions', ['method' => 'do_member_search']);
}

if (version_compare($current, '6.3.4', '<')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of add-ons updater, $current represents the add-on version, not EE version. So you would need to update version in addon.setup.php and use corresponding version in this check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, good to know; updated and pushed anew :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants