Skip to content

Commit

Permalink
Show invitation link if email server not setup (#3520)
Browse files Browse the repository at this point in the history
* return invite link to client if e-mail server is not set up

* add a couple of tests to make sure invite links are only returned when neccessary

* show invite link when e-mail is not configured

* remove "an e-mail has been sent" when there's no e-mail configured

* return invite_url in re-invites as well. Also refactor to reuse the code.

* don't create invite links when no_invite is included

* Revert "don't create invite links when no_invite is included"

This reverts commit 7fe46d9.

* don't create invite links when no_invite is included (non-stupid version)
  • Loading branch information
Omer Lachish authored Mar 3, 2019
1 parent e9603f5 commit 71f2f97
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions redash/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
)


def invite_user(org, inviter, user, send_email=True):
def invite_user(org, inviter, user):
email_configured = settings.MAIL_DEFAULT_SENDER is not None
d = user.to_dict()

invite_url = invite_link_for_user(user)
if email_configured and send_email:
if email_configured:
send_invite_email(inviter, user, invite_url, org)
else:
d['invite_link'] = invite_url
Expand Down Expand Up @@ -145,8 +145,11 @@ def post(self):
'object_type': 'user'
})

should_send_invitation = 'no_invite' not in request.args
return invite_user(self.current_org, self.current_user, user, send_email=should_send_invitation)
should_invite = 'no_invite' not in request.args
if should_invite:
return invite_user(self.current_org, self.current_user, user)
else:
return user.to_dict()


class UserInviteResource(BaseResource):
Expand Down Expand Up @@ -299,4 +302,4 @@ def delete(self, user_id):
user.enable()
models.db.session.commit()

return user.to_dict(with_api_key=is_admin_or_owner(user_id))
return user.to_dict(with_api_key=is_admin_or_owner(user_id))

0 comments on commit 71f2f97

Please sign in to comment.