Add Styler
This commit is contained in:
@@ -4,9 +4,11 @@ defmodule Tradex.Accounts do
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Tradex.Repo
|
||||
|
||||
alias Tradex.Accounts.{User, UserToken, UserNotifier}
|
||||
alias Tradex.Accounts.User
|
||||
alias Tradex.Accounts.UserNotifier
|
||||
alias Tradex.Accounts.UserToken
|
||||
alias Tradex.Repo
|
||||
|
||||
## Database getters
|
||||
|
||||
@@ -38,8 +40,7 @@ defmodule Tradex.Accounts do
|
||||
nil
|
||||
|
||||
"""
|
||||
def get_user_by_email_and_password(email, password)
|
||||
when is_binary(email) and is_binary(password) do
|
||||
def get_user_by_email_and_password(email, password) when is_binary(email) and is_binary(password) do
|
||||
user = Repo.get_by(User, email: email)
|
||||
if User.valid_password?(user, password), do: user
|
||||
end
|
||||
|
@@ -1,5 +1,7 @@
|
||||
defmodule Tradex.Accounts.User do
|
||||
@moduledoc false
|
||||
use Tradex.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "users" do
|
||||
@@ -126,7 +128,7 @@ defmodule Tradex.Accounts.User do
|
||||
Confirms the account by setting `confirmed_at`.
|
||||
"""
|
||||
def confirm_changeset(user) do
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
now = DateTime.truncate(DateTime.utc_now(), :second)
|
||||
change(user, confirmed_at: now)
|
||||
end
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule Tradex.Accounts.UserNotifier do
|
||||
@moduledoc false
|
||||
import Swoosh.Email
|
||||
|
||||
alias Tradex.Mailer
|
||||
|
@@ -1,6 +1,9 @@
|
||||
defmodule Tradex.Accounts.UserToken do
|
||||
@moduledoc false
|
||||
use Tradex.Schema
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias Tradex.Accounts.UserToken
|
||||
|
||||
@hash_algorithm :sha256
|
||||
|
@@ -1,3 +1,4 @@
|
||||
defmodule Tradex.Mailer do
|
||||
@moduledoc false
|
||||
use Swoosh.Mailer, otp_app: :tradex
|
||||
end
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule Tradex.Schema do
|
||||
@moduledoc false
|
||||
defmacro __using__(opts) do
|
||||
quote do
|
||||
use Ecto.Schema
|
||||
|
@@ -23,10 +23,11 @@ defmodule TradexWeb do
|
||||
quote do
|
||||
use Phoenix.Router, helpers: false
|
||||
|
||||
# Import common connection and controller functions to use in pipelines
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Phoenix.LiveView.Router
|
||||
|
||||
# Import common connection and controller functions to use in pipelines
|
||||
import Plug.Conn
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -17,6 +17,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
use Phoenix.Component
|
||||
use Gettext, backend: TradexWeb.Gettext
|
||||
|
||||
alias Phoenix.HTML.FormField
|
||||
alias Phoenix.LiveView.JS
|
||||
|
||||
@doc """
|
||||
@@ -278,8 +279,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
values: ~w(checkbox color date datetime-local email file month number password
|
||||
range search select tel text textarea time url week)
|
||||
|
||||
attr :field, Phoenix.HTML.FormField,
|
||||
doc: "a form field struct retrieved from the form, for example: @form[:email]"
|
||||
attr :field, FormField, doc: "a form field struct retrieved from the form, for example: @form[:email]"
|
||||
|
||||
attr :errors, :list, default: []
|
||||
attr :checked, :boolean, doc: "the checked flag for checkbox inputs"
|
||||
@@ -287,11 +287,10 @@ defmodule TradexWeb.CoreComponents do
|
||||
attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2"
|
||||
attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"
|
||||
|
||||
attr :rest, :global,
|
||||
include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
|
||||
attr :rest, :global, include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
|
||||
multiple pattern placeholder readonly required rows size step)
|
||||
|
||||
def input(%{field: %Phoenix.HTML.FormField{} = field} = assigns) do
|
||||
def input(%{field: %FormField{} = field} = assigns) do
|
||||
errors = if Phoenix.Component.used_input?(field), do: field.errors, else: []
|
||||
|
||||
assigns
|
||||
@@ -604,8 +603,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
to: selector,
|
||||
time: 300,
|
||||
transition:
|
||||
{"transition-all transform ease-out duration-300",
|
||||
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
{"transition-all transform ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
"opacity-100 translate-y-0 sm:scale-100"}
|
||||
)
|
||||
end
|
||||
@@ -615,8 +613,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
to: selector,
|
||||
time: 200,
|
||||
transition:
|
||||
{"transition-all transform ease-in duration-200",
|
||||
"opacity-100 translate-y-0 sm:scale-100",
|
||||
{"transition-all transform ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
|
||||
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
|
||||
)
|
||||
end
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserConfirmationInstructionsLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserConfirmationLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserForgotPasswordLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserLoginLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
def render(assigns) do
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserRegistrationLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserResetPasswordLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserSettingsLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@@ -1,5 +1,7 @@
|
||||
defmodule TradexWeb.Telemetry do
|
||||
@moduledoc false
|
||||
use Supervisor
|
||||
|
||||
import Telemetry.Metrics
|
||||
|
||||
def start_link(arg) do
|
||||
@@ -70,8 +72,7 @@ defmodule TradexWeb.Telemetry do
|
||||
),
|
||||
summary("tradex.repo.query.idle_time",
|
||||
unit: {:native, :millisecond},
|
||||
description:
|
||||
"The time the connection spent waiting before being checked out for the query"
|
||||
description: "The time the connection spent waiting before being checked out for the query"
|
||||
),
|
||||
|
||||
# VM Metrics
|
||||
|
@@ -1,8 +1,9 @@
|
||||
defmodule TradexWeb.UserAuth do
|
||||
@moduledoc false
|
||||
use TradexWeb, :verified_routes
|
||||
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Plug.Conn
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
||||
|
Reference in New Issue
Block a user