@@ -10,7 +10,7 @@ defmodule Eventos.Repo.Migrations.CreateAccounts do
|
||||
add :private_key, :text
|
||||
add :public_key, :text, null: false
|
||||
add :suspended, :boolean, default: false, null: false
|
||||
add :uri, :string, null: false
|
||||
add :uri, :string
|
||||
add :url, :string
|
||||
|
||||
timestamps()
|
||||
|
||||
@@ -5,8 +5,8 @@ defmodule Eventos.Repo.Migrations.CreateUsers do
|
||||
create table(:users) do
|
||||
add :email, :string, null: false
|
||||
add :role, :integer, default: 0, null: false
|
||||
add :password_hash, :string
|
||||
add :account_id, references(:accounts, on_delete: :delete_all, null: false)
|
||||
add :password_hash, :string, null: false
|
||||
add :account_id, references(:accounts, on_delete: :delete_all), null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@@ -9,9 +9,29 @@
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
import Logger
|
||||
|
||||
Eventos.Repo.delete_all Eventos.Accounts.User
|
||||
|
||||
Eventos.Accounts.User.registration_changeset(%Eventos.Accounts.User{}, %{email: "testuser@example.com", password: "secret", password_confirmation: "secret"})
|
||||
|> Eventos.Repo.insert!
|
||||
|
||||
{:ok, {privkey, pubkey}} = RsaEx.generate_keypair("4096")
|
||||
account = Ecto.Changeset.change(%Eventos.Accounts.Account{}, %{
|
||||
username: "tcit",
|
||||
description: "myaccount",
|
||||
display_name: "Thomas Citharel",
|
||||
domain: nil,
|
||||
private_key: privkey,
|
||||
public_key: pubkey,
|
||||
uri: "",
|
||||
url: ""
|
||||
})
|
||||
|
||||
user = Eventos.Accounts.User.registration_changeset(%Eventos.Accounts.User{}, %{
|
||||
email: "tcit@tcit.fr",
|
||||
password: "tcittcit",
|
||||
password_confirmation: "tcittcit"
|
||||
})
|
||||
|
||||
account_with_user = Ecto.Changeset.put_assoc(account, :user, user)
|
||||
|
||||
Eventos.Repo.insert!(account_with_user)
|
||||
|
||||
Reference in New Issue
Block a user