Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.core
Commits
12185420
Commit
12185420
authored
Aug 15, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Test if invitation token is valid before continue.
parent
d26e9520
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
9 deletions
+37
-9
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.py
..._request/SubscriptionRequestModule_requestSubscription.py
+2
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.xml
...request/SubscriptionRequestModule_requestSubscription.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
...est/SubscriptionRequestModule_requestSubscriptionProxy.py
+33
-6
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.xml
...st/SubscriptionRequestModule_requestSubscriptionProxy.xml
+1
-1
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.py
View file @
12185420
...
...
@@ -21,4 +21,5 @@ user_input_dict = {
return
context
.
SubscriptionRequestModule_requestSubscriptionProxy
(
default_email_text
,
subscription_reference
,
confirmation_required
=
bool
(
confirmation_required
),
user_input_dict
=
user_input_dict
,
target_language
=
target_language
,
batch_mode
=
0
)
token
=
token
,
user_input_dict
=
user_input_dict
,
target_language
=
target_language
,
batch_mode
=
0
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscription.xml
View file @
12185420
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
name=None, default_email_text=None, subscription_reference=None, amount=0, confirmation_required=True, target_language=None, REQUEST=None, **kw
</string>
</value>
<value>
<string>
name=None, default_email_text=None, subscription_reference=None, amount=0,
token=None,
confirmation_required=True, target_language=None, REQUEST=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
View file @
12185420
...
...
@@ -3,24 +3,51 @@ from DateTime import DateTime
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
web_site
=
context
.
getWebSiteValue
()
if
token
:
raise
error
=
""
try
:
invitation_token
=
portal
.
invitation_token_module
[
token
]
except
KeyError
:
error
=
context
.
Base_translateString
(
"Token not Found"
)
else
:
if
invitation_token
.
getValidationState
()
!=
"validated"
:
error
=
"Token is invalid or it was already used"
if
error
:
base_url
=
web_site
.
absolute_url
()
redirect_url
=
"%s/#order?name=%s&email=%s&amount=%s&subscription_reference=%s&token=%s&error=%s"
%
(
base_url
,
user_input_dict
[
'name'
],
email
,
user_input_dict
[
"amount"
],
subscription_reference
,
token
,
error
)
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
redirect_url
)
# You always needs a user here
person
,
person_is_new
=
context
.
SubscriptionRequest_createUser
(
email
,
user_input_dict
[
'name'
])
web_site
=
context
.
getWebSiteValue
()
# Check if user is already exist, otherwise redirect to ask confirmation
if
confirmation_required
and
not
person_is_new
:
base_url
=
web_site
.
absolute_url
()
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
"%s/#order_confirmation?name=%s&email=%s&amount=%s&subscription_reference=%s"
%
(
redirect_url
=
"%s/#order_confirmation?name=%s&email=%s&amount=%s&subscription_reference=%s"
%
(
base_url
,
person
.
getTitle
(),
person
.
getDefaultEmailText
(),
user_input_dict
[
"amount"
],
subscription_reference
))
subscription_reference
)
if
token
:
redirect_url
+=
"&token=%s"
%
token
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
redirect_url
)
if
target_language
is
None
:
target_language
=
context
.
getPortalObject
()
.
Localizer
.
get_selected_language
()
target_language
=
portal
.
Localizer
.
get_selected_language
()
subscription_request
=
context
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.xml
View file @
12185420
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
email, subscription_reference, confirmation_required=False, user_input_dict=None, target_language=None, batch_mode=True, REQUEST=None
</string>
</value>
<value>
<string>
email, subscription_reference, confirmation_required=False,
token=None,
user_input_dict=None, target_language=None, batch_mode=True, REQUEST=None
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment