Add 2fa to change_password endpoint

This commit is contained in:
syeopite 2021-07-15 01:19:55 -07:00
parent 71b5874380
commit 755b847ad5
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
2 changed files with 6 additions and 1 deletions

View file

@ -858,6 +858,11 @@ get "/change_password" do |env|
user = user.as(User)
sid = sid.as(String)
if user.totp_secret && env.response.cookies["2faVerified"]?.try &.value != "1" || nil
csrf_token = generate_response(sid, {":validate_2fa"}, HMAC_KEY, PG_DB)
next templated "account/validate_2fa?referer=#{env.get?("current_page")}"
end
csrf_token = generate_response(sid, {":change_password"}, HMAC_KEY, PG_DB)
templated "account/change_password"

View file

@ -27,7 +27,7 @@ class Invidious::Routes::Accounts < Invidious::Routes::BaseRoute
user = env.get? "user"
sid = env.get? "sid"
referer = get_referer(env)
referer = get_referer(env, unroll: false)
if !user
return env.redirect referer