Skip to content

Commit

Permalink
Update timeout 15mins/checkout edge point debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyranthes03 committed Jan 25, 2025
1 parent ef98ba7 commit 070f57e
Showing 1 changed file with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,13 @@ defmodule RecognizerWeb.Accounts.UserTwoFactorController do
def new(conn, _params) do
current_user_id = get_session(conn, :two_factor_user_id)
current_user = Accounts.get_user!(current_user_id)

%{notification_preference: %{two_factor: two_factor_method}} = Accounts.load_notification_preferences(current_user)
conn
# |> maybe_send_two_factor_notification(current_user, two_factor_method)
|> render("new.html", two_factor_method: two_factor_method)
end

@doc """
Verify a user creating a session with a two factor code
"""
def create(conn, %{"user" => %{"two_factor_code" => two_factor_code}}) do
current_user_id = get_session(conn, :two_factor_user_id)
current_user = Accounts.get_user!(current_user_id)
current_time = System.system_time(:second)
%{notification_preference: %{two_factor: two_factor_method}} = Accounts.load_notification_preferences(current_user)

conn =
if get_session(conn, :two_factor_issue_time) == nil do
conn = put_session(conn, :two_factor_issue_time, current_time)
conn
|> put_session(:two_factor_issue_time, current_time)
else
conn
end
Expand All @@ -61,16 +49,32 @@ defmodule RecognizerWeb.Accounts.UserTwoFactorController do

two_factor_sent = get_session(conn, :two_factor_sent)

conn = if two_factor_sent do
IO.inspect("send_two_factor_notification" , label: "Create")
IO.inspect(two_factor_sent, label: "Two factor sent")

conn = if two_factor_sent == false do
IO.inspect("send_two_factor_notification" , label: "New")

conn
|> put_session(:two_factor_sent, false)
|> put_session(:two_factor_sent, true)
|> put_session(:two_factor_issue_time, current_time)
|> send_two_factor_notification(current_user, two_factor_method)
else
conn
end

conn
# |> maybe_send_two_factor_notification(current_user, two_factor_method)
|> render("new.html", two_factor_method: two_factor_method)
end

@doc """
Verify a user creating a session with a two factor code
"""
def create(conn, %{"user" => %{"two_factor_code" => two_factor_code}}) do
current_user_id = get_session(conn, :two_factor_user_id)
current_user = Accounts.get_user!(current_user_id)
current_time = System.system_time(:second)
%{notification_preference: %{two_factor: two_factor_method}} = Accounts.load_notification_preferences(current_user)

two_factor_issue_time = get_session(conn, :two_factor_issue_time)

Expand Down

0 comments on commit 070f57e

Please sign in to comment.