Commit 8e44da9e authored by Łukasz Nowak's avatar Łukasz Nowak

Allow asynchronous user creation.

Reuse 202 code, same like with request, to inform, that user has been allowed
to access, but not created yet.
parent 5f71731f
...@@ -168,12 +168,18 @@ def responseSupport(anonymous=False): ...@@ -168,12 +168,18 @@ def responseSupport(anonymous=False):
'GET, OPTIONS') 'GET, OPTIONS')
if not anonymous: if not anonymous:
if getSecurityManager().getUser().getId() is None: if getSecurityManager().getUser().getId() is None:
# force login if self.REQUEST.get('USER_CREATION_IN_PROGRESS') is not None:
self.REQUEST.response.setStatus(401) # inform that user is not ready yet
self.REQUEST.response.setHeader('WWW-Authenticate', 'Bearer realm="%s"'% self.REQUEST.response.setStatus(202)
self.absolute_url()) self.REQUEST.response.setBody(jsonify(
self.REQUEST.response.setHeader('Location', self.getPortalObject()\ {'status':'User under creation.'}))
.portal_preferences.getPreferredRestApiV1TokenServerUrl()) else:
# force login
self.REQUEST.response.setStatus(401)
self.REQUEST.response.setHeader('WWW-Authenticate', 'Bearer realm="%s"'%
self.absolute_url())
self.REQUEST.response.setHeader('Location', self.getPortalObject()\
.portal_preferences.getPreferredRestApiV1TokenServerUrl())
return self.REQUEST.response return self.REQUEST.response
else: else:
user_name = self.getPortalObject().portal_membership\ user_name = self.getPortalObject().portal_membership\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment