Skip to content

Instantly share code, notes, and snippets.

@thebrianemory
Created November 3, 2017 15:22
Show Gist options
  • Save thebrianemory/a6351dae79be65ed02b56a39e67ff2c7 to your computer and use it in GitHub Desktop.
Save thebrianemory/a6351dae79be65ed02b56a39e67ff2c7 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/@your_domain.com$/) do # Change your_domain to your domain
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