mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-10 06:01:44 +08:00
Fix user information to include payload returned from identity provider (#2890)
This commit is contained in:
parent
dba7cbf7be
commit
2d9b6f8dac
2 changed files with 10 additions and 2 deletions
|
|
@ -42,13 +42,14 @@ defmodule Livebook.Users.User do
|
||||||
name: nil,
|
name: nil,
|
||||||
email: nil,
|
email: nil,
|
||||||
avatar_url: nil,
|
avatar_url: nil,
|
||||||
|
payload: nil,
|
||||||
hex_color: Livebook.EctoTypes.HexColor.random()
|
hex_color: Livebook.EctoTypes.HexColor.random()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeset(user, attrs \\ %{}) do
|
def changeset(user, attrs \\ %{}) do
|
||||||
user
|
user
|
||||||
|> cast(attrs, [:name, :email, :avatar_url, :hex_color])
|
|> cast(attrs, [:name, :email, :avatar_url, :hex_color, :payload])
|
||||||
|> validate_required([:hex_color])
|
|> validate_required([:hex_color])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,19 @@ defmodule Livebook.Users.UserTest do
|
||||||
describe "change/2" do
|
describe "change/2" do
|
||||||
test "given valid attributes returns and updated user" do
|
test "given valid attributes returns and updated user" do
|
||||||
user = build(:user)
|
user = build(:user)
|
||||||
attrs = %{"name" => "Jake Peralta", "hex_color" => "#000000"}
|
|
||||||
|
attrs = %{
|
||||||
|
"name" => "Jake Peralta",
|
||||||
|
"hex_color" => "#000000",
|
||||||
|
"payload" => %{"country" => "US"}
|
||||||
|
}
|
||||||
|
|
||||||
changeset = User.changeset(user, attrs)
|
changeset = User.changeset(user, attrs)
|
||||||
|
|
||||||
assert changeset.valid?
|
assert changeset.valid?
|
||||||
assert get_field(changeset, :name) == "Jake Peralta"
|
assert get_field(changeset, :name) == "Jake Peralta"
|
||||||
assert get_field(changeset, :hex_color) == "#000000"
|
assert get_field(changeset, :hex_color) == "#000000"
|
||||||
|
assert get_field(changeset, :payload) == %{"country" => "US"}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "given invalid color returns an error" do
|
test "given invalid color returns an error" do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue