mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
only update usage counters on valid TOTP (fixes philomena-dev/philomena#50)
This commit is contained in:
parent
c30c8e3136
commit
1e2c57d8e8
1 changed files with 10 additions and 1 deletions
|
@ -124,7 +124,16 @@ defmodule PhilomenaWeb.UserAuth do
|
||||||
user = user_token && Users.get_user_by_session_token(user_token)
|
user = user_token && Users.get_user_by_session_token(user_token)
|
||||||
totp = totp_token && Users.user_totp_token_valid?(user, totp_token)
|
totp = totp_token && Users.user_totp_token_valid?(user, totp_token)
|
||||||
|
|
||||||
if user, do: update_usages(conn, user)
|
cond do
|
||||||
|
user && user.otp_required_for_login && totp ->
|
||||||
|
update_usages(conn, user)
|
||||||
|
|
||||||
|
user && !user.otp_required_for_login ->
|
||||||
|
update_usages(conn, user)
|
||||||
|
|
||||||
|
true ->
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> assign(:current_user, user)
|
|> assign(:current_user, user)
|
||||||
|
|
Loading…
Reference in a new issue