mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 21:03:23 +12:00
docs: Update oauth docs (#745)
This commit is contained in:
parent
5d4f20be17
commit
58ee13adaf
2 changed files with 43 additions and 2 deletions
|
@ -117,7 +117,7 @@ defmodule MyApp.Accounts.User do
|
||||||
argument :user_info, :map, allow_nil?: false
|
argument :user_info, :map, allow_nil?: false
|
||||||
argument :oauth_tokens, :map, allow_nil?: false
|
argument :oauth_tokens, :map, allow_nil?: false
|
||||||
upsert? true
|
upsert? true
|
||||||
upsert_identity :email
|
upsert_identity :unique_email
|
||||||
|
|
||||||
# Required if you have token generation enabled.
|
# Required if you have token generation enabled.
|
||||||
change AshAuthentication.GenerateTokenChange
|
change AshAuthentication.GenerateTokenChange
|
||||||
|
@ -137,3 +137,23 @@ defmodule MyApp.Accounts.User do
|
||||||
|
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ensure you set the `hashed_password` to `allow_nil?` if you are also using the password strategy.
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
defmodule MyApp.Accounts.User do
|
||||||
|
# ...
|
||||||
|
attributes do
|
||||||
|
# ...
|
||||||
|
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true
|
||||||
|
end
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
And generate and run migrations in that case.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mix ash.codegen make_hashed_password_nullable
|
||||||
|
mix ash.migrate
|
||||||
|
```
|
||||||
|
|
|
@ -7,6 +7,7 @@ First you'll need a registered application in [Google Cloud](https://console.clo
|
||||||
1. On the Cloud's console **Quick access** section select **APIs & Services**, then **Credentials**
|
1. On the Cloud's console **Quick access** section select **APIs & Services**, then **Credentials**
|
||||||
2. Click on **+ CREATE CREDENTIALS** and from the dropdown select **OAuth client ID**
|
2. Click on **+ CREATE CREDENTIALS** and from the dropdown select **OAuth client ID**
|
||||||
3. From the google developers console, we will need: `client_id` & `client_secret`
|
3. From the google developers console, we will need: `client_id` & `client_secret`
|
||||||
|
4. Enter your callback uri under **Authorized redirect URIs**. E.g. `http://localhost:4000/auth/user/google/callback`.
|
||||||
|
|
||||||
Next we configure our resource to use google credentials:
|
Next we configure our resource to use google credentials:
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ defmodule MyApp.Accounts.User do
|
||||||
argument :user_info, :map, allow_nil?: false
|
argument :user_info, :map, allow_nil?: false
|
||||||
argument :oauth_tokens, :map, allow_nil?: false
|
argument :oauth_tokens, :map, allow_nil?: false
|
||||||
upsert? true
|
upsert? true
|
||||||
upsert_identity :email
|
upsert_identity :unique_email
|
||||||
|
|
||||||
change AshAuthentication.GenerateTokenChange
|
change AshAuthentication.GenerateTokenChange
|
||||||
|
|
||||||
|
@ -66,3 +67,23 @@ defmodule MyApp.Accounts.User do
|
||||||
|
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ensure you set the `hashed_password` to `allow_nil?` if you are also using the password strategy.
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
defmodule MyApp.Accounts.User do
|
||||||
|
# ...
|
||||||
|
attributes do
|
||||||
|
# ...
|
||||||
|
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true
|
||||||
|
end
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
And generate and run migrations in that case.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mix ash.codegen make_hashed_password_nullable
|
||||||
|
mix ash.migrate
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue