Skip to content

Commit

Permalink
Update docs to account for unconfirmed users
Browse files Browse the repository at this point in the history
Ensure oauth users cannot login with unconfirmed account team-alembic#443
  • Loading branch information
dan-klasson committed Aug 19, 2024
1 parent 5d4f20b commit 51131fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions documentation/tutorials/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ defmodule MyApp.Accounts.User do

Ash.Changeset.change_attributes(changeset, Map.take(user_info, ["email"]))
end

# Required if you're using the password & confirmation strategies
upsert_fields []
change set_attribute(:confirmed_at, &DateTime.utc_now/0)
change after_action(fn _changeset, user, _context ->
case user.confirmed_at do
nil -> {:error, "Unconfirmed user exists already"}
_ -> {:ok, user}
end
end)
end
end

Expand Down
10 changes: 10 additions & 0 deletions documentation/tutorials/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ defmodule MyApp.Accounts.User do

Ash.Changeset.change_attributes(changeset, Map.take(user_info, ["email"]))
end

# Required if you're using the password & confirmation strategies
upsert_fields []
change set_attribute(:confirmed_at, &DateTime.utc_now/0)
change after_action(fn _changeset, user, _context ->
case user.confirmed_at do
nil -> {:error, "Unconfirmed user exists already"}
_ -> {:ok, user}
end
end)
end
end

Expand Down

0 comments on commit 51131fc

Please sign in to comment.