Scaffhold token interface
This commit is contained in:
parent
529cde4836
commit
2a406ef236
|
@ -7,6 +7,9 @@ defmodule Hostas.Denizen do
|
|||
field :name, :string
|
||||
field :password, :string
|
||||
|
||||
# Links entries in the "tokens" table to denizens
|
||||
has_many(:tokens, Hostas.Token)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
|
|
|
@ -3,16 +3,19 @@ defmodule Hostas.Token do
|
|||
import Ecto.Changeset
|
||||
|
||||
schema "tokens" do
|
||||
field :id, :integer
|
||||
field :denizen_id, :integer
|
||||
field :expires, :utc_datetime
|
||||
|
||||
# Link tokens to denizens
|
||||
belongs_to :denizens, Hostas.Denizen
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(token, attrs) do
|
||||
token
|
||||
|> cast(attrs, [:id, :expires])
|
||||
|> validate_required([:id, :expires])
|
||||
|> cast(attrs, [:denizen_id, :expires])
|
||||
|> validate_required([:denizen_id, :expires])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
defmodule HostasWeb.Auth.TokenController do
|
||||
use HostasWeb, :controller
|
||||
|
||||
def index(_conn, _params) do
|
||||
:ok
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
defmodule HostasWeb.AuthenticationController do
|
||||
use HostasWeb, :controller
|
||||
|
||||
def join(conn, _params) do
|
||||
:ok
|
||||
end
|
||||
end
|
|
@ -23,7 +23,7 @@ defmodule HostasWeb.Router do
|
|||
scope "/hostapi/", HostasWeb do
|
||||
pipe_through :api
|
||||
|
||||
post "/auth/register", AuthenticationController, :register
|
||||
resources "/auth/token", Auth.TokenController
|
||||
end
|
||||
|
||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule Hostas.Repo.Migrations.CreateTokens do
|
|||
|
||||
def change do
|
||||
create table(:tokens) do
|
||||
add :id, :integer
|
||||
add :denizen_id, :integer
|
||||
add :expires, :utc_datetime
|
||||
|
||||
timestamps()
|
Loading…
Reference in New Issue