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

Email otp #48

Merged
merged 48 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
219cf67
Email OTP code validation
folix-01 Apr 11, 2024
3b17d93
Lint
folix-01 Apr 11, 2024
9ade0e4
Fix
folix-01 Apr 11, 2024
c70a05f
Fixes
folix-01 Apr 11, 2024
ea779ab
Fix
folix-01 Apr 11, 2024
3cfd598
Changelog
folix-01 Apr 11, 2024
28af374
Update locales
folix-01 Apr 11, 2024
00ad9d0
Use pyotp to generate and verify the token
folix-01 Apr 11, 2024
e5ed15a
Formatting
folix-01 Apr 11, 2024
c8e6a84
Fixes
folix-01 Apr 11, 2024
fb20eeb
Fix conflicts
folix-01 Apr 11, 2024
47c167f
Fix tests
folix-01 Apr 11, 2024
442c98e
Relax coverage
folix-01 Apr 12, 2024
491bbbc
Fix readme
folix-01 Apr 12, 2024
8de329b
Rename endpoint
folix-01 Apr 12, 2024
cc26f8e
Fixes
folix-01 Apr 12, 2024
95f2cc5
Colors
folix-01 Apr 12, 2024
ee50518
Fix logics
folix-01 Apr 12, 2024
b194b94
Fix logics
folix-01 Apr 16, 2024
107ac28
Translations
folix-01 Apr 16, 2024
05ff6bf
Use secret
folix-01 Apr 16, 2024
2ce13e5
Fix otp field name
folix-01 Apr 16, 2024
6bd35e3
fix tests
folix-01 Apr 16, 2024
676ceaa
Merge branch 'main' into email_otp
folix-01 Apr 16, 2024
c20cd7b
Fix code
folix-01 Apr 16, 2024
999db2a
Windows mailserver compatibility
folix-01 Apr 16, 2024
ecfc473
Lint
folix-01 Apr 16, 2024
0323f3f
Update locales
folix-01 Apr 16, 2024
cc370ee
Explicit help text for email
folix-01 Apr 16, 2024
08ffe5a
Helptext
folix-01 Apr 16, 2024
be2998e
Update locales
folix-01 Apr 16, 2024
29cb068
Update template
folix-01 Apr 16, 2024
53a01e2
Locales
folix-01 Apr 16, 2024
d5ef336
Template fixed
folix-01 Apr 16, 2024
9410074
locales
folix-01 Apr 16, 2024
424388d
Locales
folix-01 Apr 16, 2024
a7594df
Update locales
folix-01 Apr 16, 2024
21935a6
Template
folix-01 Apr 16, 2024
fb2318a
Update locales
folix-01 Apr 16, 2024
d82e34b
Fix template
folix-01 Apr 16, 2024
dbe77bf
Fixes
folix-01 Apr 17, 2024
c80234b
Form
folix-01 Apr 17, 2024
4569cd3
---
folix-01 Apr 17, 2024
7b2cb25
Fix zcml
folix-01 Apr 17, 2024
ade3597
Fix translation
folix-01 Apr 17, 2024
988b363
Fix
folix-01 Apr 17, 2024
0821cd8
Fix template
folix-01 Apr 17, 2024
fb2ac8d
Translations
folix-01 Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
2.7.1 (unreleased)
------------------

- Add functionality to check the user iserted email by an OTP.
cekk marked this conversation as resolved.
Show resolved Hide resolved
[folix-01]
- Breaking change: clear data method changed from GET to DELETE
[mamico]
- Fix: with multiple blocks on the same page, all data is deleted.
Expand Down
31 changes: 29 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,38 @@ Reset the store (only for users that have **Modify portal content** permission):

> curl -i -X DELETE http://localhost:8080/Plone/my-form/@form-data-clear --data-raw '{block_id: bbb}' -H 'Accept: application/json' -H 'Content-Type: application/json' --user admin:admin

Optional paramaters could be passed in the payload:
Optional paramaters could be passed in the payload:
cekk marked this conversation as resolved.
Show resolved Hide resolved

* `block_id` to delete only data related to a specific block on the page, otherwise data from all form blocks on the page will be deleted
* `expired` a boolean that, if `true`, removes only records older than the value of days specified in the block configuration (the above `block_id` parameter is required)

@validate-email-message
-----------------------

Send an message to the passed email wit OTP code to verify the address.
Returns a HTTP 204 in case of success or HTTP 400 in case if the email is badly composed.::

> curl -i -X POST http://localhost:8080/Plone/my-form/@validate-email-message --data-raw '{'email': "email@email.com"}' -H 'Accept: application/json' -H 'Content-Type: application/json'

paramaters:
cekk marked this conversation as resolved.
Show resolved Hide resolved

* `email` email address.
* `uid` uid related to email field

@validate-email-token
---------------------

Supposed to validate the OTP code recieved by user via email.
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

Copy link
Member Author

Choose a reason for hiding this comment

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

solved

Returns HTTP 204 in case of success or HTTP 400 in case of failure ::

> curl -i -X POST http://localhost:8080/Plone/my-form/@validate-email-token --data-raw '{'email': "email@email.com", "token": "blahblahblah"}' -H 'Accept: application/json' -H 'Content-Type: application/json'

paramaters:
cekk marked this conversation as resolved.
Show resolved Hide resolved

* `email` email address
* `uid` uid used to generate the OTP
* `token` OTP code

Form actions
============

Expand Down Expand Up @@ -276,7 +303,7 @@ There is a script that implements data cleansing (i.e. for GDPR purpose)::
--help Show this message and exit.


The form block as an integer field `remove_data_after_days`, the retention days can be defined on a single block,
The form block as an integer field `remove_data_after_days`, the retention days can be defined on a single block,
If the value is lower or equal to `0` there is no data cleaning for the specific form.

Examples
Expand Down
1 change: 1 addition & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ eggs =
Plone
Pillow
collective.volto.formsupport [test]
plone.keyring

zcml-additional +=
<configure xmlns="http://namespaces.zope.org/zope"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"plone.app.dexterity",
"souper.plone",
"click",
"pyotp",
],
extras_require={
"hcaptcha": [
Expand Down
9 changes: 9 additions & 0 deletions src/collective/volto/formsupport/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@
template="send_mail_template_table.pt"
permission="zope2.View"
/>
<browser:page
name="email-confirm-view"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".email_confirm_view.EmailConfirmView"
template="templates/email_confirm_view.pt"
permission="zope2.View"
layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer"
/>

</configure>
16 changes: 16 additions & 0 deletions src/collective/volto/formsupport/browser/email_confirm_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from plone import api
from Products.Five.browser import BrowserView


class EmailConfirmView(BrowserView):
def __call__(self, token="alksdjfakls", *args, **kwargs):
self.token = token

return super().__call__(*args, **kwargs)

def get_token(self):
return self.token

def get_portal(self):
return api.portal.get()
Loading
Loading