def invite_user(service_id, user_id=None): if current_service.has_permission('broadcast'): form_class = BroadcastInviteUserForm else: form_class = InviteUserForm form = form_class( invalid_email_address=current_user.email_address, all_template_folders=current_service.all_template_folders, folder_permissions=[ f['id'] for f in current_service.all_template_folders ]) if user_id: user_to_invite = User.from_id(user_id) if user_to_invite.belongs_to_service(current_service.id): return render_template( 'views/user-already-team-member.html', user_to_invite=user_to_invite, ) if current_service.invite_pending_for(user_to_invite.email_address): return render_template( 'views/user-already-invited.html', user_to_invite=user_to_invite, ) if not user_to_invite.default_organisation: abort(403) if user_to_invite.default_organisation.id != current_service.organisation_id: abort(403) form.email_address.data = user_to_invite.email_address else: user_to_invite = None service_has_email_auth = current_service.has_permission('email_auth') if not service_has_email_auth: form.login_authentication.data = 'sms_auth' if form.validate_on_submit(): email_address = form.email_address.data invited_user = InvitedUser.create( current_user.id, service_id, email_address, form.permissions, form.login_authentication.data, form.folder_permissions.data, ) flash('Invite sent to {}'.format(invited_user.email_address), 'default_with_tick') return redirect(url_for('.manage_users', service_id=service_id)) return render_template( 'views/invite-user.html', form=form, service_has_email_auth=service_has_email_auth, mobile_number=True, user_to_invite=user_to_invite, )
def invite_user(service_id): form = InviteUserForm( invalid_email_address=current_user.email_address, all_template_folders=current_service.all_template_folders, folder_permissions=[ f['id'] for f in current_service.all_template_folders ]) service_has_email_auth = current_service.has_permission('email_auth') if not service_has_email_auth: form.login_authentication.data = 'sms_auth' if form.validate_on_submit(): email_address = form.email_address.data invited_user = InvitedUser.create( current_user.id, service_id, email_address, form.permissions, form.login_authentication.data, form.folder_permissions.data, ) flash('{} {}'.format(_l('Invite sent to'), invited_user.email_address), 'default_with_tick') return redirect(url_for('.manage_users', service_id=service_id)) return render_template( 'views/invite-user.html', form=form, service_has_email_auth=service_has_email_auth, mobile_number=True, )
def invite_user(service_id): form = InviteUserForm( invalid_email_address=current_user.email_address, all_template_folders=current_service.all_template_folders, folder_permissions=[ f["id"] for f in current_service.all_template_folders ], ) service_has_email_auth = current_service.has_permission("email_auth") if not service_has_email_auth: form.login_authentication.data = "sms_auth" if form.validate_on_submit(): email_address = form.email_address.data invited_user = InvitedUser.create( current_user.id, service_id, email_address, form.permissions, form.login_authentication.data, form.folder_permissions.data, ) flash( "{} {}".format(_l("Invite sent to"), invited_user.email_address), "default_with_tick", ) return redirect(url_for(".manage_users", service_id=service_id)) return render_template( "views/invite-user.html", form=form, service_has_email_auth=service_has_email_auth, mobile_number=True, )