refactored for new project name

This commit is contained in:
Adam Piontek 2021-03-05 19:23:32 -05:00
parent 0039146cd4
commit 82ab1d1ea5
113 changed files with 417 additions and 412 deletions

2
.gitignore vendored
View file

@ -24,7 +24,7 @@ erl_crash.dump
*.ez
# Ignore package tarball (built via "mix hex.build").
bones73k-*.tar
shift73k-*.tar
# If NPM crashes, it generates a log, let's ignore it too.
npm-debug.log

View file

@ -1,5 +1,5 @@
import Ecto.Query
# alias Bones73kWeb.Router.Helpers, as: Routes
alias Bones73k.Repo
alias Bones73k.Accounts
alias Bones73k.Accounts.User
# alias Shift73kWeb.Router.Helpers, as: Routes
alias Shift73k.Repo
alias Shift73k.Accounts
alias Shift73k.Accounts.User

View file

@ -1,4 +1,4 @@
# Bones73k
# Shift73k
See full article [here](https://www.leanpanda.com/blog/authentication-and-authorisation-in-phoenix-liveview/).

View file

@ -7,21 +7,21 @@
# General application configuration
use Mix.Config
config :bones73k,
ecto_repos: [Bones73k.Repo]
config :shift73k,
ecto_repos: [Shift73k.Repo]
# Custom application global variables
config :bones73k, :app_global_vars,
config :shift73k, :app_global_vars,
time_zone: "America/New_York",
mailer_reply_to: "reply_to@example.com",
mailer_from: "app_name@example.com"
# Configures the endpoint
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "LdIQmzV5UCWSbB2SdiWFHLgxYNObKq9Za/VyguoILxfOAMDb5IsptKCKtXTRn+Tf",
render_errors: [view: Bones73kWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Bones73k.PubSub,
render_errors: [view: Shift73kWeb.ErrorView, accepts: ~w(html json), layout: false],
pubsub_server: Shift73k.PubSub,
live_view: [signing_salt: "2D4GC4ac"]
# Configures Elixir's Logger

View file

@ -1,10 +1,10 @@
use Mix.Config
# Configure your database
config :bones73k, Bones73k.Repo,
config :shift73k, Shift73k.Repo,
username: "postgres",
password: "postgres",
database: "bones73k_dev",
database: "shift73k_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
@ -15,7 +15,7 @@ config :bones73k, Bones73k.Repo,
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
@ -56,13 +56,13 @@ config :bones73k, Bones73kWeb.Endpoint,
# different ports.
# Watch static and templates for browser reloading.
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/bones73k_web/(live|views)/.*(ex)$",
~r"lib/bones73k_web/templates/.*(eex)$"
~r"lib/shift73k_web/(live|views)/.*(ex)$",
~r"lib/shift73k_web/templates/.*(eex)$"
]
]

View file

@ -9,7 +9,7 @@ use Mix.Config
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
@ -21,7 +21,7 @@ config :logger, level: :info
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :bones73k, Bones73kWeb.Endpoint,
# config :shift73k, Shift73kWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [
@ -45,7 +45,7 @@ config :logger, level: :info
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
# config :bones73k, Bones73kWeb.Endpoint,
# config :shift73k, Shift73kWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

View file

@ -11,7 +11,7 @@ database_url =
For example: ecto://USER:PASS@HOST/DATABASE
"""
config :bones73k, Bones73k.Repo,
config :shift73k, Shift73k.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
@ -23,7 +23,7 @@ secret_key_base =
You can generate one by calling: mix phx.gen.secret
"""
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
http: [
port: String.to_integer(System.get_env("PORT") || "4000"),
transport_options: [socket_opts: [:inet6]]
@ -35,7 +35,7 @@ config :bones73k, Bones73kWeb.Endpoint,
# If you are doing OTP releases, you need to instruct Phoenix
# to start each relevant endpoint:
#
# config :bones73k, Bones73kWeb.Endpoint, server: true
# config :shift73k, Shift73kWeb.Endpoint, server: true
#
# Then you can assemble a release by calling `mix release`.
# See `mix help release` for more information.

View file

@ -8,16 +8,16 @@ config :bcrypt_elixir, :log_rounds, 1
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :bones73k, Bones73k.Repo,
config :shift73k, Shift73k.Repo,
username: "postgres",
password: "postgres",
database: "bones73k_test#{System.get_env("MIX_TEST_PARTITION")}",
database: "shift73k_test#{System.get_env("MIX_TEST_PARTITION")}",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
# We don't run a server during test. If one is required,
# you can enable the server option below.
config :bones73k, Bones73kWeb.Endpoint,
config :shift73k, Shift73kWeb.Endpoint,
http: [port: 4002],
server: false
@ -25,7 +25,7 @@ config :bones73k, Bones73kWeb.Endpoint,
config :logger, level: :warn
# Bamboo test mailer config
config :bones73k, Bones73k.Mailer, adapter: Bamboo.TestAdapter
config :shift73k, Shift73k.Mailer, adapter: Bamboo.TestAdapter
# Import secret config
import_config "test.secret.exs"

View file

@ -1,3 +0,0 @@
defmodule Bones73k.Mailer do
use Bamboo.Mailer, otp_app: :bones73k
end

View file

@ -1,8 +0,0 @@
defmodule Bones73kWeb.UserRegistrationController do
use Bones73kWeb, :controller
import Phoenix.LiveView.Controller
def new(conn, _params) do
live_render(conn, Bones73kWeb.UserLive.Registration)
end
end

View file

@ -1,3 +0,0 @@
defmodule Bones73kWeb.OtherView do
use Bones73kWeb, :view
end

View file

@ -1,4 +0,0 @@
defmodule Bones73kWeb.UserConfirmationView do
use Bones73kWeb, :view
alias Bones73k.Accounts.User
end

View file

@ -1,4 +0,0 @@
defmodule Bones73kWeb.UserResetPasswordView do
use Bones73kWeb, :view
alias Bones73k.Accounts.User
end

View file

@ -1,4 +0,0 @@
defmodule Bones73kWeb.UserSessionView do
use Bones73kWeb, :view
alias Bones73k.Accounts.User
end

View file

@ -1,6 +1,6 @@
defmodule Bones73k do
defmodule Shift73k do
@moduledoc """
Bones73k keeps the contexts that define your domain
Shift73k keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless

View file

@ -1,12 +1,12 @@
defmodule Bones73k.Accounts do
defmodule Shift73k.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
alias Bones73k.Repo
alias Bones73k.Accounts.{User, UserToken, UserNotifier}
alias Bones73kWeb.UserAuth
alias Shift73k.Repo
alias Shift73k.Accounts.{User, UserToken, UserNotifier}
alias Shift73kWeb.UserAuth
## Database getters
@ -121,7 +121,7 @@ defmodule Bones73k.Accounts do
Repo.delete_all(UserToken.user_and_contexts_query(user, :all))
# Broadcast to all liveviews to immediately disconnect the user
Bones73kWeb.Endpoint.broadcast_from(
Shift73kWeb.Endpoint.broadcast_from(
self(),
UserAuth.pubsub_topic(),
"logout_user",

View file

@ -1,4 +1,4 @@
defmodule Bones73k.Accounts.User do
defmodule Shift73k.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
import EctoEnum
@ -19,12 +19,12 @@ defmodule Bones73k.Accounts.User do
@primary_key {:id, :binary_id, autogenerate: true}
# @foreign_key_type :binary_id
schema "users" do
field :email, :string
field :password, :string, virtual: true
field :hashed_password, :string
field :confirmed_at, :naive_datetime
field(:email, :string)
field(:password, :string, virtual: true)
field(:hashed_password, :string)
field(:confirmed_at, :naive_datetime)
field :role, RolesEnum, default: :user
field(:role, RolesEnum, default: :user)
timestamps()
end
@ -102,7 +102,7 @@ defmodule Bones73k.Accounts.User do
defp validate_email(changeset) do
changeset
|> validate_email_format()
|> unsafe_validate_unique(:email, Bones73k.Repo)
|> unsafe_validate_unique(:email, Shift73k.Repo)
|> unique_constraint(:email)
end
@ -173,7 +173,7 @@ defmodule Bones73k.Accounts.User do
If there is no user or the user doesn't have a password, we call
`Bcrypt.no_user_verify/0` to avoid timing attacks.
"""
def valid_password?(%Bones73k.Accounts.User{hashed_password: hashed_password}, password)
def valid_password?(%Shift73k.Accounts.User{hashed_password: hashed_password}, password)
when is_binary(hashed_password) and byte_size(password) > 0 do
Bcrypt.verify_pass(password, hashed_password)
end

View file

@ -1,6 +1,6 @@
defmodule Bones73k.Accounts.UserNotifier do
alias Bones73k.Mailer
alias Bones73k.Mailer.UserEmail
defmodule Shift73k.Accounts.UserNotifier do
alias Shift73k.Mailer
alias Shift73k.Mailer.UserEmail
@doc """
Deliver instructions to confirm account.

View file

@ -1,4 +1,4 @@
defmodule Bones73k.Accounts.UserToken do
defmodule Shift73k.Accounts.UserToken do
use Ecto.Schema
import Ecto.Query
@ -15,10 +15,10 @@ defmodule Bones73k.Accounts.UserToken do
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "users_tokens" do
field :token, :binary
field :context, :string
field :sent_to, :string
belongs_to :user, Bones73k.Accounts.User
field(:token, :binary)
field(:context, :string)
field(:sent_to, :string)
belongs_to(:user, Shift73k.Accounts.User)
timestamps(updated_at: false)
end
@ -30,7 +30,7 @@ defmodule Bones73k.Accounts.UserToken do
"""
def build_session_token(user) do
token = :crypto.strong_rand_bytes(@rand_size)
{token, %Bones73k.Accounts.UserToken{token: token, context: "session", user_id: user.id}}
{token, %Shift73k.Accounts.UserToken{token: token, context: "session", user_id: user.id}}
end
@doc """
@ -40,10 +40,11 @@ defmodule Bones73k.Accounts.UserToken do
"""
def verify_session_token_query(token) do
query =
from token in token_and_context_query(token, "session"),
from(token in token_and_context_query(token, "session"),
join: user in assoc(token, :user),
where: token.inserted_at > ago(@session_validity_in_days, "day"),
select: user
)
{:ok, query}
end
@ -65,7 +66,7 @@ defmodule Bones73k.Accounts.UserToken do
hashed_token = :crypto.hash(@hash_algorithm, token)
{Base.url_encode64(token, padding: false),
%Bones73k.Accounts.UserToken{
%Shift73k.Accounts.UserToken{
token: hashed_token,
context: context,
sent_to: sent_to,
@ -85,10 +86,11 @@ defmodule Bones73k.Accounts.UserToken do
days = days_for_context(context)
query =
from token in token_and_context_query(hashed_token, context),
from(token in token_and_context_query(hashed_token, context),
join: user in assoc(token, :user),
where: token.inserted_at > ago(^days, "day") and token.sent_to == user.email,
select: user
)
{:ok, query}
@ -111,8 +113,9 @@ defmodule Bones73k.Accounts.UserToken do
hashed_token = :crypto.hash(@hash_algorithm, decoded_token)
query =
from token in token_and_context_query(hashed_token, context),
from(token in token_and_context_query(hashed_token, context),
where: token.inserted_at > ago(@change_email_validity_in_days, "day")
)
{:ok, query}
@ -125,17 +128,17 @@ defmodule Bones73k.Accounts.UserToken do
Returns the given token with the given context.
"""
def token_and_context_query(token, context) do
from Bones73k.Accounts.UserToken, where: [token: ^token, context: ^context]
from(Shift73k.Accounts.UserToken, where: [token: ^token, context: ^context])
end
@doc """
Gets all tokens for the given user for the given contexts.
"""
def user_and_contexts_query(user, :all) do
from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id
from(t in Shift73k.Accounts.UserToken, where: t.user_id == ^user.id)
end
def user_and_contexts_query(user, [_ | _] = contexts) do
from t in Bones73k.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts
from(t in Shift73k.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts)
end
end

View file

@ -1,4 +1,4 @@
defmodule Bones73k.Application do
defmodule Shift73k.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
@ -8,27 +8,27 @@ defmodule Bones73k.Application do
def start(_type, _args) do
children = [
# Start the Ecto repository
Bones73k.Repo,
Shift73k.Repo,
# Start the Telemetry supervisor
Bones73kWeb.Telemetry,
Shift73kWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: Bones73k.PubSub},
{Phoenix.PubSub, name: Shift73k.PubSub},
# Start the Endpoint (http/https)
Bones73kWeb.Endpoint
# Start a worker by calling: Bones73k.Worker.start_link(arg)
# {Bones73k.Worker, arg}
Shift73kWeb.Endpoint
# Start a worker by calling: Shift73k.Worker.start_link(arg)
# {Shift73k.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Bones73k.Supervisor]
opts = [strategy: :one_for_one, name: Shift73k.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
Bones73kWeb.Endpoint.config_change(changed, removed)
Shift73kWeb.Endpoint.config_change(changed, removed)
:ok
end
end

3
lib/shift73k/mailer.ex Normal file
View file

@ -0,0 +1,3 @@
defmodule Shift73k.Mailer do
use Bamboo.Mailer, otp_app: :shift73k
end

View file

@ -1,9 +1,9 @@
defmodule Bones73k.Mailer.UserEmail do
defmodule Shift73k.Mailer.UserEmail do
import Bamboo.Email
@mailer_vars Application.get_env(:bones73k, :app_global_vars,
@mailer_vars Application.get_env(:shift73k, :app_global_vars,
mailer_reply_to: "admin@example.com",
mailer_from: {"Bones73k", "bones73k@example.com"}
mailer_from: {"Shift73k", "shift73k@example.com"}
)
def compose(user, subject, body_text) do

View file

@ -1,12 +1,12 @@
defmodule Bones73k.Properties do
defmodule Shift73k.Properties do
@moduledoc """
The Properties context.
"""
import Ecto.Query, warn: false
alias Bones73k.Repo
alias Shift73k.Repo
alias Bones73k.Properties.Property
alias Shift73k.Properties.Property
@doc """
Returns the list of properties.

View file

@ -1,14 +1,14 @@
defmodule Bones73k.Properties.Property do
defmodule Shift73k.Properties.Property do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "properties" do
field :description, :string
field :name, :string
field :price, :decimal
field :user_id, :binary_id
field(:description, :string)
field(:name, :string)
field(:price, :decimal)
field(:user_id, :binary_id)
timestamps()
end

View file

@ -1,6 +1,6 @@
defmodule Bones73k.Repo do
defmodule Shift73k.Repo do
use Ecto.Repo,
otp_app: :bones73k,
otp_app: :shift73k,
adapter: Ecto.Adapters.Postgres
use Scrivener, page_size: 10

View file

@ -1,5 +1,5 @@
defmodule Bones73k.Util.Dt do
@app_vars Application.get_env(:bones73k, :app_global_vars, time_zone: "America/New_York")
defmodule Shift73k.Util.Dt do
@app_vars Application.get_env(:shift73k, :app_global_vars, time_zone: "America/New_York")
@time_zone @app_vars[:time_zone]
def ndt_to_local(%NaiveDateTime{} = ndt), do: Timex.to_datetime(ndt, @time_zone)

View file

@ -1,12 +1,12 @@
defmodule Bones73kWeb do
defmodule Shift73kWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use Bones73kWeb, :controller
use Bones73kWeb, :view
use Shift73kWeb, :controller
use Shift73kWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
@ -19,19 +19,19 @@ defmodule Bones73kWeb do
def controller do
quote do
use Phoenix.Controller, namespace: Bones73kWeb
use Phoenix.Controller, namespace: Shift73kWeb
import Plug.Conn
import Bones73kWeb.Gettext
alias Bones73kWeb.Router.Helpers, as: Routes
import Shift73kWeb.Gettext
alias Shift73kWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/bones73k_web/templates",
namespace: Bones73kWeb,
root: "lib/shift73k_web/templates",
namespace: Shift73kWeb,
pattern: "**/*"
# Import convenience functions from controllers
@ -46,12 +46,12 @@ defmodule Bones73kWeb do
def live_view do
quote do
use Phoenix.LiveView,
layout: {Bones73kWeb.LayoutView, "live.html"}
layout: {Shift73kWeb.LayoutView, "live.html"}
unquote(view_helpers())
import Bones73kWeb.LiveHelpers
import Shift73kWeb.LiveHelpers
alias Bones73k.Accounts.User
alias Shift73k.Accounts.User
@impl true
def handle_info(%{event: "logout_user", payload: %{user: %User{id: id}}}, socket) do
@ -71,7 +71,7 @@ defmodule Bones73kWeb do
use Phoenix.LiveComponent
# Import General Custom Live Helpers
import Bones73kWeb.LiveHelpers
import Shift73kWeb.LiveHelpers
unquote(view_helpers())
end
@ -90,7 +90,7 @@ defmodule Bones73kWeb do
def channel do
quote do
use Phoenix.Channel
import Bones73kWeb.Gettext
import Shift73kWeb.Gettext
end
end
@ -106,11 +106,11 @@ defmodule Bones73kWeb do
import Phoenix.View
# Import SVG Icon helper
import Bones73kWeb.IconHelpers
import Shift73kWeb.IconHelpers
import Bones73kWeb.ErrorHelpers
import Bones73kWeb.Gettext
alias Bones73kWeb.Router.Helpers, as: Routes
import Shift73kWeb.ErrorHelpers
import Shift73kWeb.Gettext
alias Shift73kWeb.Router.Helpers, as: Routes
end
end

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserSocket do
defmodule Shift73kWeb.UserSocket do
use Phoenix.Socket
## Channels
# channel "room:*", Bones73kWeb.RoomChannel
# channel "room:*", Shift73kWeb.RoomChannel
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
@ -27,7 +27,7 @@ defmodule Bones73kWeb.UserSocket do
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# Bones73kWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
# Shift73kWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
@impl true

View file

@ -1,5 +1,5 @@
defmodule Bones73kWeb.OtherController do
use Bones73kWeb, :controller
defmodule Shift73kWeb.OtherController do
use Shift73kWeb, :controller
def index(conn, _params) do
conn

View file

@ -1,9 +1,9 @@
defmodule Bones73kWeb.UserAuth do
defmodule Shift73kWeb.UserAuth do
import Plug.Conn
import Phoenix.Controller
alias Bones73k.Accounts
alias Bones73kWeb.Router.Helpers, as: Routes
alias Shift73k.Accounts
alias Shift73kWeb.Router.Helpers, as: Routes
@pubsub_topic "user_updates"
@ -76,7 +76,7 @@ defmodule Bones73kWeb.UserAuth do
user_token && Accounts.delete_session_token(user_token)
if live_socket_id = get_session(conn, :live_socket_id) do
Bones73kWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{})
Shift73kWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{})
end
conn

View file

@ -1,7 +1,7 @@
defmodule Bones73kWeb.UserConfirmationController do
use Bones73kWeb, :controller
defmodule Shift73kWeb.UserConfirmationController do
use Shift73kWeb, :controller
alias Bones73k.Accounts
alias Shift73k.Accounts
def new(conn, _params) do
render(conn, "new.html")

View file

@ -0,0 +1,8 @@
defmodule Shift73kWeb.UserRegistrationController do
use Shift73kWeb, :controller
import Phoenix.LiveView.Controller
def new(conn, _params) do
live_render(conn, Shift73kWeb.UserLive.Registration)
end
end

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserResetPasswordController do
use Bones73kWeb, :controller
defmodule Shift73kWeb.UserResetPasswordController do
use Shift73kWeb, :controller
import Phoenix.LiveView.Controller
alias Bones73k.Accounts
alias Shift73k.Accounts
plug(:get_user_by_reset_password_token when action in [:edit])
@ -28,7 +28,7 @@ defmodule Bones73kWeb.UserResetPasswordController do
end
def edit(conn, _params) do
live_render(conn, Bones73kWeb.UserLive.ResetPassword)
live_render(conn, Shift73kWeb.UserLive.ResetPassword)
end
defp get_user_by_reset_password_token(conn, _opts) do

View file

@ -1,10 +1,10 @@
defmodule Bones73kWeb.UserSessionController do
use Bones73kWeb, :controller
defmodule Shift73kWeb.UserSessionController do
use Shift73kWeb, :controller
alias Phoenix.HTML
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Bones73kWeb.UserAuth
alias Shift73k.Accounts
alias Shift73k.Accounts.User
alias Shift73kWeb.UserAuth
def new(conn, _params) do
render(conn, "new.html", error_message: nil)
@ -24,7 +24,7 @@ defmodule Bones73kWeb.UserSessionController do
end
def create(conn, %{"user" => %{"params_token" => token} = user_params}) do
with {:ok, params} <- Phoenix.Token.decrypt(Bones73kWeb.Endpoint, "login_params", token),
with {:ok, params} <- Phoenix.Token.decrypt(Shift73kWeb.Endpoint, "login_params", token),
%User{} = user <- Accounts.get_user(params.user_id) do
conn
|> collect_messages(params.messages)

View file

@ -1,7 +1,7 @@
defmodule Bones73kWeb.UserSettingsController do
use Bones73kWeb, :controller
defmodule Shift73kWeb.UserSettingsController do
use Shift73kWeb, :controller
alias Bones73k.Accounts
alias Shift73k.Accounts
def confirm_email(conn, %{"token" => token}) do
case Accounts.update_user_email(conn.assigns.current_user, token) do

View file

@ -1,16 +1,16 @@
defmodule Bones73kWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :bones73k
defmodule Shift73kWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :shift73k
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_bones73k_key",
key: "_shift73k_key",
signing_salt: "9CKxo0VJ"
]
socket("/socket", Bones73kWeb.UserSocket,
socket("/socket", Shift73kWeb.UserSocket,
websocket: true,
longpoll: false
)
@ -23,7 +23,7 @@ defmodule Bones73kWeb.Endpoint do
# when deploying your static files in production.
plug(Plug.Static,
at: "/",
from: :bones73k,
from: :shift73k,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
)
@ -34,7 +34,7 @@ defmodule Bones73kWeb.Endpoint do
socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
plug(Phoenix.LiveReloader)
plug(Phoenix.CodeReloader)
plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :bones73k)
plug(Phoenix.Ecto.CheckRepoStatus, otp_app: :shift73k)
end
plug(Phoenix.LiveDashboard.RequestLogger,
@ -54,5 +54,5 @@ defmodule Bones73kWeb.Endpoint do
plug(Plug.MethodOverride)
plug(Plug.Head)
plug(Plug.Session, @session_options)
plug(Bones73kWeb.Router)
plug(Shift73kWeb.Router)
end

View file

@ -1,11 +1,11 @@
defmodule Bones73kWeb.Gettext do
defmodule Shift73kWeb.Gettext do
@moduledoc """
A module providing Internationalization with a gettext-based API.
By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example:
import Bones73kWeb.Gettext
import Shift73kWeb.Gettext
# Simple translation
gettext("Here is the string to translate")
@ -20,5 +20,5 @@ defmodule Bones73kWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :bones73k
use Gettext, otp_app: :shift73k
end

View file

@ -1,5 +1,5 @@
defmodule Bones73kWeb.AdminDashboardLive do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.AdminDashboardLive do
use Shift73kWeb, :live_view
@impl true
def mount(_params, session, socket) do

View file

@ -1,10 +1,10 @@
defmodule Bones73kWeb.LiveHelpers do
defmodule Shift73kWeb.LiveHelpers do
import Phoenix.LiveView
import Phoenix.LiveView.Helpers
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Bones73kWeb.UserAuth
alias Shift73k.Accounts
alias Shift73k.Accounts.User
alias Shift73kWeb.UserAuth
@doc """
Performs the {:noreply, socket} for a given socket.
@ -19,14 +19,14 @@ defmodule Bones73kWeb.LiveHelpers do
def live_okreply(socket), do: {:ok, socket}
@doc """
Renders a component inside the `Bones73kWeb.ModalComponent` component.
Renders a component inside the `Shift73kWeb.ModalComponent` component.
The rendered modal receives a `:return_to` option to properly update
the URL when the modal is closed.
## Examples
<%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
<%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent,
id: @property.id || :new,
action: @live_action,
property: @property,
@ -36,14 +36,14 @@ defmodule Bones73kWeb.LiveHelpers do
modal_opts = [id: :modal, component: component, opts: opts]
# dirty little workaround for elixir complaining about socket being unused
_socket = socket
live_component(socket, Bones73kWeb.ModalComponent, modal_opts)
live_component(socket, Shift73kWeb.ModalComponent, modal_opts)
end
@doc """
Loads default assigns for liveviews
"""
def assign_defaults(socket, session) do
Bones73kWeb.Endpoint.subscribe(UserAuth.pubsub_topic())
Shift73kWeb.Endpoint.subscribe(UserAuth.pubsub_topic())
assign_current_user(socket, session)
end

View file

@ -1,5 +1,5 @@
defmodule Bones73kWeb.ModalComponent do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.ModalComponent do
use Shift73kWeb, :live_component
@impl true
def render(assigns) do

View file

@ -1,5 +1,5 @@
defmodule Bones73kWeb.PageLive do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.PageLive do
use Shift73kWeb, :live_view
@impl true
def mount(_params, session, socket) do
@ -27,7 +27,7 @@ defmodule Bones73kWeb.PageLive do
end
defp search(query) do
if not Bones73kWeb.Endpoint.config(:code_reloader) do
if not Shift73kWeb.Endpoint.config(:code_reloader) do
raise "action disabled when not in development"
end

View file

@ -1,7 +1,7 @@
defmodule Bones73kWeb.PropertyLive.FormComponent do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.PropertyLive.FormComponent do
use Shift73kWeb, :live_component
alias Bones73k.Properties
alias Shift73k.Properties
@impl true
def update(%{property: property} = assigns, socket) do

View file

@ -1,9 +1,9 @@
defmodule Bones73kWeb.PropertyLive.Index do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.PropertyLive.Index do
use Shift73kWeb, :live_view
alias Bones73k.Properties
alias Bones73k.Properties.Property
alias Bones73kWeb.Roles
alias Shift73k.Properties
alias Shift73k.Properties.Property
alias Shift73kWeb.Roles
@impl true
def mount(_params, session, socket) do
@ -54,7 +54,7 @@ defmodule Bones73kWeb.PropertyLive.Index do
current_user = socket.assigns.current_user
property = Properties.get_property!(id)
if Bones73kWeb.Roles.can?(current_user, property, :delete) do
if Shift73kWeb.Roles.can?(current_user, property, :delete) do
property = Properties.get_property!(id)
{:ok, _} = Properties.delete_property(property)

View file

@ -1,5 +1,5 @@
<%= if @live_action in [:new, :edit] do %>
<%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
<%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent,
id: @property.id || :new,
title: @page_title,
action: @live_action,

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.PropertyLive.Show do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.PropertyLive.Show do
use Shift73kWeb, :live_view
alias Bones73k.Properties
alias Bones73kWeb.Roles
alias Shift73k.Properties
alias Shift73kWeb.Roles
@impl true
def mount(_params, session, socket) do

View file

@ -1,7 +1,7 @@
<h2>Show Property</h2>
<%= if @live_action in [:edit] do %>
<%= live_modal @socket, Bones73kWeb.PropertyLive.FormComponent,
<%= live_modal @socket, Shift73kWeb.PropertyLive.FormComponent,
id: @property.id,
title: @page_title,
action: @live_action,

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserLive.Registration do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.UserLive.Registration do
use Shift73kWeb, :live_view
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Shift73k.Accounts
alias Shift73k.Accounts.User
@impl true
def mount(_params, session, socket) do

View file

@ -63,7 +63,7 @@
<%# hidden form for initial login after registration %>
<%= form_for :user, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit, id: "reg_trigger"], fn f -> %>
<%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %>
<%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %>
<% end %>
</div>

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserLive.ResetPassword do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.UserLive.ResetPassword do
use Shift73kWeb, :live_view
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Shift73k.Accounts
alias Shift73k.Accounts.User
@impl true
def mount(_params, session, socket) do

View file

@ -1,7 +1,7 @@
defmodule Bones73kWeb.UserLive.Settings do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.UserLive.Settings do
use Shift73kWeb, :live_view
alias Bones73k.Accounts.User
alias Shift73k.Accounts.User
@impl true
def mount(_params, session, socket) do

View file

@ -4,6 +4,6 @@
</h2>
<div class="row">
<%= live_component @socket, Bones73kWeb.UserLive.Settings.Email, id: "email-#{@current_user.id}", current_user: @current_user %>
<%= live_component @socket, Bones73kWeb.UserLive.Settings.Password, id: "password-#{@current_user.id}", current_user: @current_user %>
<%= live_component @socket, Shift73kWeb.UserLive.Settings.Email, id: "email-#{@current_user.id}", current_user: @current_user %>
<%= live_component @socket, Shift73kWeb.UserLive.Settings.Password, id: "password-#{@current_user.id}", current_user: @current_user %>
</div>

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserLive.Settings.Email do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.UserLive.Settings.Email do
use Shift73kWeb, :live_component
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Shift73k.Accounts
alias Shift73k.Accounts.User
@impl true
def update(%{current_user: user} = assigns, socket) do
@ -23,7 +23,7 @@ defmodule Bones73kWeb.UserLive.Settings.Email do
{:noreply, assign(socket, changeset: %{cs | action: :validate})}
end
# user_settings_path GET /users/settings/confirm_email/:token Bones73kWeb.UserSettingsController :confirm_email
# user_settings_path GET /users/settings/confirm_email/:token Shift73kWeb.UserSettingsController :confirm_email
@impl true
def handle_event("save", %{"user" => user_params}, socket) do

View file

@ -1,8 +1,8 @@
defmodule Bones73kWeb.UserLive.Settings.Password do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.UserLive.Settings.Password do
use Shift73kWeb, :live_component
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Shift73k.Accounts
alias Shift73k.Accounts.User
@impl true
def update(%{current_user: user} = assigns, socket) do

View file

@ -65,12 +65,12 @@
<%# hidden form for initial login after registration %>
<%= form_for :user, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit, id: "settings_pw_change_trigger"], fn f -> %>
<%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %>
<%= hidden_input f, :params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %>
<% end %>
<%# hidden form to submit user for relogin after password change %>
<%#= form_for :user_login, Routes.user_session_path(@socket, :create), [phx_trigger_action: @trigger_submit], fn f -> %>
<%#= hidden_input f, :login_params_token, value: Phoenix.Token.encrypt(Bones73kWeb.Endpoint, "login_params", @login_params) %>
<%#= hidden_input f, :login_params_token, value: Phoenix.Token.encrypt(Shift73kWeb.Endpoint, "login_params", @login_params) %>
<%#= hidden_input f, :remember_me, value: false %>
<%# end %>

View file

@ -1,5 +1,5 @@
defmodule Bones73kWeb.UserDashboardLive do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.UserDashboardLive do
use Shift73kWeb, :live_view
@impl true
def mount(_params, session, socket) do

View file

@ -1,7 +1,7 @@
defmodule Bones73kWeb.UserManagement.DeleteComponent do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.UserManagement.DeleteComponent do
use Shift73kWeb, :live_component
alias Bones73k.Accounts
alias Shift73k.Accounts
@impl true
def update(assigns, socket) do

View file

@ -1,9 +1,9 @@
defmodule Bones73kWeb.UserManagement.FormComponent do
use Bones73kWeb, :live_component
defmodule Shift73kWeb.UserManagement.FormComponent do
use Shift73kWeb, :live_component
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Bones73kWeb.Roles
alias Shift73k.Accounts
alias Shift73k.Accounts.User
alias Shift73kWeb.Roles
@impl true
def update(assigns, socket) do

View file

@ -1,14 +1,14 @@
defmodule Bones73kWeb.UserManagementLive.Index do
use Bones73kWeb, :live_view
defmodule Shift73kWeb.UserManagementLive.Index do
use Shift73kWeb, :live_view
import Ecto.Query
import Bones73kWeb.Pagination
import Bones73k.Util.Dt
import Shift73kWeb.Pagination
import Shift73k.Util.Dt
alias Bones73k.Repo
alias Bones73k.Accounts
alias Bones73k.Accounts.User
alias Bones73kWeb.Roles
alias Shift73k.Repo
alias Shift73k.Accounts
alias Shift73k.Accounts.User
alias Shift73kWeb.Roles
@impl true
def mount(_params, session, socket) do