user state + signup templates
* added new templates for signup * changed task type for openstack SignUp to 'signup' * making the templates change based on the user state (default/existing/disabled) Change-Id: I3d8209fd15425d6f8eefb9c03ad891c26c3b20f8
This commit is contained in:
parent
258b6a54c1
commit
66bc146f59
|
@ -125,7 +125,7 @@ DEFAULT_TASK_SETTINGS:
|
|||
|
||||
# These are cascading overrides for the default settings:
|
||||
TASK_SETTINGS:
|
||||
create_project:
|
||||
signup:
|
||||
# You can override 'default_actions' if needed for given taskviews
|
||||
# The order of the actions is order of execution.
|
||||
#
|
||||
|
@ -138,6 +138,16 @@ TASK_SETTINGS:
|
|||
- AddDefaultUsersToProjectAction
|
||||
- NewProjectDefaultNetworkAction
|
||||
- SetProjectQuotaAction
|
||||
emails:
|
||||
initial:
|
||||
subject: Your OpenStack signup has been received
|
||||
template: signup_initial.txt
|
||||
token:
|
||||
subject: Your OpenStack signup has been approved
|
||||
template: signup_token.txt
|
||||
completed:
|
||||
subject: Your OpenStack signup has been completed
|
||||
template: signup_completed.txt
|
||||
notifications:
|
||||
standard:
|
||||
EmailNotification:
|
||||
|
|
|
@ -383,6 +383,8 @@ class NewUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
user = self._get_target_user()
|
||||
if not user:
|
||||
self.action.need_token = True
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "default"
|
||||
self.set_token_fields(["password"])
|
||||
self.add_note(
|
||||
'No user present with username. Need to create new user.')
|
||||
|
@ -396,6 +398,8 @@ class NewUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
if not user.enabled:
|
||||
self.action.need_token = True
|
||||
self.action.state = "disabled"
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "disabled"
|
||||
# as they are disabled we'll reset their password
|
||||
self.set_token_fields(["password"])
|
||||
self.add_note(
|
||||
|
@ -417,6 +421,8 @@ class NewUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
self.action.need_token = True
|
||||
self.set_token_fields(["confirm"])
|
||||
self.action.state = "existing"
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "existing"
|
||||
self.add_note(
|
||||
'Existing user with matching email missing roles.')
|
||||
|
||||
|
@ -647,6 +653,8 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
user = id_manager.find_user(self.username, self.domain_id)
|
||||
|
||||
if not user:
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "default"
|
||||
self.action.need_token = True
|
||||
self.set_token_fields(["password"])
|
||||
self.add_note("No user present with username '%s'." %
|
||||
|
@ -660,6 +668,8 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
|
||||
if not user.enabled:
|
||||
self.action.state = "disabled"
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "disabled"
|
||||
self.action.need_token = True
|
||||
self.add_note(
|
||||
"Existing disabled user '%s' with matching email." %
|
||||
|
@ -667,6 +677,8 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin):
|
|||
return True
|
||||
else:
|
||||
self.action.state = "existing"
|
||||
# add to cache to use in template
|
||||
self.action.task.cache['user_state'] = "existing"
|
||||
self.action.need_token = False
|
||||
self.add_note("Existing user '%s' with matching email." %
|
||||
self.email)
|
||||
|
|
|
@ -446,7 +446,8 @@ class ActionTests(TestCase):
|
|||
'test_project')
|
||||
self.assertEquals(
|
||||
task.cache,
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1'})
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1',
|
||||
'user_state': 'default'})
|
||||
|
||||
token_data = {'password': '123456'}
|
||||
action.submit(token_data)
|
||||
|
@ -497,7 +498,8 @@ class ActionTests(TestCase):
|
|||
'test_project')
|
||||
self.assertEquals(
|
||||
task.cache,
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1'})
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1',
|
||||
'user_state': 'default'})
|
||||
|
||||
action.post_approve()
|
||||
self.assertEquals(action.valid, True)
|
||||
|
@ -506,7 +508,8 @@ class ActionTests(TestCase):
|
|||
'test_project')
|
||||
self.assertEquals(
|
||||
task.cache,
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1'})
|
||||
{'project_id': 'project_id_1', 'user_id': 'user_id_1',
|
||||
'user_state': 'default'})
|
||||
|
||||
token_data = {'password': '123456'}
|
||||
action.submit(token_data)
|
||||
|
@ -563,7 +566,8 @@ class ActionTests(TestCase):
|
|||
'test_project')
|
||||
self.assertEquals(
|
||||
task.cache,
|
||||
{'user_id': 'user_id_1', 'project_id': 'project_id_1'})
|
||||
{'user_id': 'user_id_1', 'project_id': 'project_id_1',
|
||||
'user_state': 'existing'})
|
||||
|
||||
token_data = {'password': '123456'}
|
||||
action.submit(token_data)
|
||||
|
@ -621,7 +625,8 @@ class ActionTests(TestCase):
|
|||
'test_project')
|
||||
self.assertEquals(
|
||||
task.cache,
|
||||
{'user_id': 'user_id_1', 'project_id': 'project_id_1'})
|
||||
{'user_id': 'user_id_1', 'project_id': 'project_id_1',
|
||||
'user_state': 'disabled'})
|
||||
|
||||
token_data = {'password': '123456'}
|
||||
action.submit(token_data)
|
||||
|
|
|
@ -286,6 +286,8 @@ class SignUp(tasks.CreateProject):
|
|||
The openstack endpoint for signups.
|
||||
"""
|
||||
|
||||
task_type = "signup"
|
||||
|
||||
def get(self, request):
|
||||
"""
|
||||
The SignUp endpoint does not support GET.
|
||||
|
|
|
@ -9,7 +9,7 @@ This link expires automatically after 24 hours. If expired, you can simply go to
|
|||
|
||||
Once this is done you will have access to the dashboard and APIs.
|
||||
|
||||
You can find examples and documentation on using Openstack at http://www.openstack.org/
|
||||
You can find examples and documentation on using Openstack at http://docs.openstack.org/
|
||||
|
||||
Kind regards,
|
||||
The Openstack team
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
You have been invited by {{ task.keystone_user.username }} to join the project '{{ task.keystone_user.project_name }}' on Openstack.
|
||||
Please click on this link to accept the invitation: {{ tokenurl }}{{ token }}
|
||||
|
||||
New users will be asked to define a password when accepting the invitation.
|
||||
Existing users will be added to the project and do not need to provide additional information.
|
||||
Please click on this link to accept the invitation:
|
||||
{{ tokenurl }}{{ token }}
|
||||
|
||||
{% if task.cache.user_state == "default" %}
|
||||
You will be asked to define a password when accepting the invitation. After that you will be given access to the project and will be able to login.
|
||||
{% elif task.cache.user_state == "existing" %}
|
||||
As an existing user you will be added to the project and do not need to provide additional information. All you have to do is click confirm.
|
||||
{% elif task.cache.user_state == "disabled" %}
|
||||
It appears you already have a user account that was disabled. We've reactivated it, but because it may have been a while we've reset your password. After you setup your new password you will be given access to the project and will be able to login.
|
||||
{% endif %}
|
||||
|
||||
This link will expire automatically after 24 hours. If expired, you will need to request another one from the person who invited you.
|
||||
|
||||
Kind regards,
|
||||
The Openstack team
|
||||
The Openstack team
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{% if task.cache.user_state == "default" %}
|
||||
This email is to confirm that your Openstack signup has been completed and your new user and password have now been set up.
|
||||
{% elif task.cache.user_state == "existing" %}
|
||||
This email is to confirm that your Openstack signup has been completed and your existing user has access to your new project.
|
||||
{% elif task.cache.user_state == "disabled" %}
|
||||
This email is to confirm that your Openstack signup has been completed and your existing user has been re-enabled and given access to your new project.
|
||||
{% endif %}
|
||||
|
||||
If you did not do this yourself, please get in touch with your systems administrator to report suspicious activity and secure your account.
|
||||
|
||||
Kind regards,
|
||||
The Openstack team
|
|
@ -0,0 +1,8 @@
|
|||
Hello,
|
||||
|
||||
Your signup is in our system and now waiting approval.
|
||||
|
||||
Once someone has approved it you will be emailed an update.
|
||||
|
||||
Kind regards,
|
||||
The Openstack team
|
|
@ -0,0 +1,17 @@
|
|||
Your OpenStack sign-up has been approved!
|
||||
|
||||
Please follow this link to finalise access to your new OpenStack project:
|
||||
{{ tokenurl }}{{ token }}
|
||||
|
||||
{% if task.cache.user_state == "default" %}
|
||||
You will be asked to define a password, after that you will be given access to the project and will be able to login
|
||||
{% elif task.cache.user_state == "disabled" %}
|
||||
It appears you already have a user account that was disabled. We've reactivated it, but because it may have been a while we've reset your password. After you setup your new password you will be given access to your new project and will be able to login.
|
||||
{% endif %}
|
||||
|
||||
This link expires automatically after 24 hours. If expired, you can simply go to the dashboard and request a password reset.
|
||||
|
||||
You can find examples and documentation on using Openstack at http://docs.openstack.org/
|
||||
|
||||
Kind regards,
|
||||
The Openstack team
|
|
@ -123,6 +123,20 @@ TASK_SETTINGS = {
|
|||
}
|
||||
},
|
||||
'create_project': {
|
||||
'emails': {
|
||||
'initial': {
|
||||
'template': 'signup_initial.txt',
|
||||
'subject': 'signup received'
|
||||
},
|
||||
'token': {
|
||||
'template': 'signup_token.txt',
|
||||
'subject': 'signup approved'
|
||||
},
|
||||
'completed': {
|
||||
'template': 'signup_completed.txt',
|
||||
'subject': 'signup completed'
|
||||
}
|
||||
},
|
||||
'additional_actions': [
|
||||
'AddDefaultUsersToProjectAction',
|
||||
'NewProjectDefaultNetworkAction'
|
||||
|
|
Loading…
Reference in New Issue