Commit 0bc43aa6 authored by Alex Castaño's avatar Alex Castaño

Whitelist moodle emails

parent 81ff827f
......@@ -218,6 +218,7 @@ defmodule MoodleNet.Accounts do
end
def is_email_in_whitelist?(email) do
Repo.get(WhitelistEmail, email) != nil
String.ends_with?(email, "@moodle.com") ||
Repo.get(WhitelistEmail, email) != nil
end
end
......@@ -25,6 +25,14 @@ defmodule MoodleNet.AccountsTest do
assert_delivered_email(MoodleNet.Email.welcome(ret.user, ret.email_confirmation_token.token))
end
test "works with moodle.com emails" do
icon_attrs = Factory.attributes(:image)
attrs = Factory.attributes(:user, email: "any_email_or_whatever@moodle.com")
assert {:ok, _} = Accounts.register_user(attrs)
end
test "fails with invalid password values" do
attrs = Factory.attributes(:user) |> Map.delete("password")
Accounts.add_email_to_whitelist(attrs["email"])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment