mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
feat(portal): enable welcome email sending on manually provisionned o… (#5679)
…idc users (#5127) Currently we can only send a welcome email to oidc users who have already logged in once. For manually provisionned oidc users, we can't. This PR aims to solve this issue --------- Co-authored-by: Antoine <antoinelabarussias@gmail.com>
This commit is contained in:
@@ -926,7 +926,8 @@ defmodule Web.CoreComponents do
|
||||
end
|
||||
|
||||
def identity_has_email?(identity) do
|
||||
not is_nil(provider_email(identity)) or identity.provider.adapter == :email
|
||||
not is_nil(provider_email(identity)) or identity.provider.adapter == :email or
|
||||
identity.provider_identifier =~ "@"
|
||||
end
|
||||
|
||||
defp provider_email(identity) do
|
||||
|
||||
@@ -501,7 +501,34 @@ defmodule Web.Live.Actors.ShowTest do
|
||||
}
|
||||
)
|
||||
|
||||
oidc_identity = Fixtures.Auth.create_identity(account: account, actor: actor)
|
||||
{oidc_provider, _bypass} =
|
||||
Fixtures.Auth.start_and_create_openid_connect_provider(account: account)
|
||||
|
||||
oidc_manually_provisioned_identity =
|
||||
Fixtures.Auth.create_identity(
|
||||
account: account,
|
||||
actor: actor,
|
||||
provider: oidc_provider,
|
||||
provider_identifier: Fixtures.Auth.email()
|
||||
)
|
||||
|
||||
oidc_identity =
|
||||
Fixtures.Auth.create_identity(
|
||||
account: account,
|
||||
actor: actor,
|
||||
provider: oidc_provider,
|
||||
provider_state: %{
|
||||
"userinfo" => %{"email" => Fixtures.Auth.email()}
|
||||
}
|
||||
)
|
||||
|
||||
oidc_identity_with_no_email =
|
||||
Fixtures.Auth.create_identity(
|
||||
account: account,
|
||||
actor: actor,
|
||||
provider: oidc_provider,
|
||||
provider_identifier: "sub123"
|
||||
)
|
||||
|
||||
email_identity =
|
||||
Fixtures.Auth.create_identity(account: account, actor: actor, provider: email_provider)
|
||||
@@ -524,9 +551,23 @@ defmodule Web.Live.Actors.ShowTest do
|
||||
|> element("#identity-#{google_identity.id} button", "Send Welcome Email")
|
||||
|> has_element?()
|
||||
|
||||
refute lv
|
||||
assert lv
|
||||
|> element(
|
||||
"#identity-#{oidc_manually_provisioned_identity.id} button",
|
||||
"Send Welcome Email"
|
||||
)
|
||||
|> has_element?()
|
||||
|
||||
assert lv
|
||||
|> element("#identity-#{oidc_identity.id} button", "Send Welcome Email")
|
||||
|> has_element?()
|
||||
|
||||
refute lv
|
||||
|> element(
|
||||
"#identity-#{oidc_identity_with_no_email.id} button",
|
||||
"Send Welcome Email"
|
||||
)
|
||||
|> has_element?()
|
||||
end
|
||||
|
||||
test "allows deleting identities", %{
|
||||
|
||||
Reference in New Issue
Block a user