Skip to content

Instantly share code, notes, and snippets.

@thebrianemory
Created November 22, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebrianemory/06b2c9fcd9afe9772df6ee312efd2f6d to your computer and use it in GitHub Desktop.
Save thebrianemory/06b2c9fcd9afe9772df6ee312efd2f6d to your computer and use it in GitHub Desktop.
defp authenticate(%{info: info, uid: uid}) do
email = Map.get(info, :email)
name = Developer.format_username(Map.get(info, :name))
case String.match?(email, ~r/@yourdomain.com$/) do # Add your domain on this line
true ->
attrs = %{
email: email,
username: name,
google_id: uid
}
Developer.find_or_create(Repo, attrs)
_ ->
{:error, email}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment