mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Merge pull request #18 from danbee/hound-will-probably-have-a-lot-to-say
Unleash the Hound! 🐕
This commit is contained in:
commit
00ff6ee218
2
.hound.yml
Normal file
2
.hound.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
credo:
|
||||||
|
enabled: true
|
||||||
@ -1,4 +1,6 @@
|
|||||||
defmodule Chess do
|
defmodule Chess do
|
||||||
|
@moduledoc false
|
||||||
|
|
||||||
use Application
|
use Application
|
||||||
|
|
||||||
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
||||||
|
|||||||
@ -105,10 +105,11 @@ defmodule Chess.Auth do
|
|||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def authenticate_user(username, password) do
|
def authenticate_user(username, password) do
|
||||||
Repo.one(
|
query = from u in User,
|
||||||
from u in User,
|
where: u.username == ^username
|
||||||
where: u.username == ^username
|
|
||||||
)
|
query
|
||||||
|
|> Repo.one
|
||||||
|> Argon2.check_pass(password)
|
|> Argon2.check_pass(password)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
defmodule Chess.Auth.Guardian do
|
defmodule Chess.Auth.Guardian do
|
||||||
|
@moduledoc false
|
||||||
|
|
||||||
use Guardian, otp_app: :chess
|
use Guardian, otp_app: :chess
|
||||||
|
|
||||||
alias Chess.Auth
|
alias Chess.Auth
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
defmodule Chess.Board do
|
defmodule Chess.Board do
|
||||||
|
@moduledoc false
|
||||||
|
|
||||||
def output(board) do
|
def output(board) do
|
||||||
Enum.map(0..7, fn (rank) ->
|
Enum.map(0..7, fn (rank) ->
|
||||||
Enum.map(0..7, fn (file) ->
|
Enum.map(0..7, fn (file) ->
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
defmodule Chess.Store.Game do
|
defmodule Chess.Store.Game do
|
||||||
|
@moduledoc false
|
||||||
|
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
use Timex.Ecto.Timestamps
|
use Timex.Ecto.Timestamps
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,12 @@ defmodule ChessWeb.GameController do
|
|||||||
|
|
||||||
def index(conn, _params) do
|
def index(conn, _params) do
|
||||||
changeset = Game.changeset(%Game{})
|
changeset = Game.changeset(%Game{})
|
||||||
games = Game
|
games =
|
||||||
|> Game.for_user(current_user(conn))
|
Game
|
||||||
|> Game.ordered
|
|> Game.for_user(current_user(conn))
|
||||||
|> Repo.all
|
|> Game.ordered
|
||||||
|
|> Repo.all
|
||||||
|
|
||||||
render(conn, "index.html", games: games, changeset: changeset)
|
render(conn, "index.html", games: games, changeset: changeset)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ defmodule ChessWeb.GameController do
|
|||||||
|
|
||||||
def show(conn, %{"id" => id}) do
|
def show(conn, %{"id" => id}) do
|
||||||
game = Repo.get!(Game, id)
|
game = Repo.get!(Game, id)
|
||||||
|
|
||||||
render(conn, "show.html", game: game)
|
render(conn, "show.html", game: game)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user