-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInvite User.py
85 lines (78 loc) · 2.79 KB
/
Invite User.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
This flow script invites an user to cloudomation.
It queries the name and email address of the new user and creates a user
object. The new user has to validate the email address by clicking on the
activation link. The new user also has to set a password.
"""
def handler(system, this):
inputs = this.get('input_value') or {}
message_id = inputs.get('message_id')
if message_id is None:
# Query user details
message = system.message(
subject='Invite a new user to join your client',
body={
'type': 'object',
'properties': {
'name_info': {
'element': 'markdown',
'example': 'Please enter a login name of the user you want to invite',
'order': 1,
},
'name': {
'element': 'string',
'type': 'string',
'example': 'newuser',
'maxLength': 32,
'label': 'User name',
'order': 2,
},
'email_info': {
'element': 'markdown',
'example': (
'Please enter the email address of the user you want to invite.'
'The user will receive an email with a link to accept the invitation.'
),
'order': 3,
},
'email': {
'element': 'string',
'type': 'string',
'format': 'email',
'example': '[email protected]',
'label': 'Email address',
'order': 4,
},
'Send invitation': {
'element': 'submit',
'type': 'boolean',
'order': 5,
},
},
'required': [
'name',
'email',
],
}
)
message_id = message.get('id')
this.save(output_value={
'message_id': message_id,
})
this.flow(
'Invite User',
message_id=message_id,
wait=False,
)
return this.success('requested details')
message = system.message(message_id)
response = message.wait().get('response')
this.log(response=response)
# Create user object
system.user(
select=None,
name=response['name'],
pending_email=response['email'],
)
# Success
return this.success(f'{response["name"]} was invited to cloudomation')