mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-29 07:58:35 +00:00
Add some comments
This commit is contained in:
parent
2d289b3d12
commit
0fd4beeac8
@ -156,6 +156,7 @@ module Invidious::Routes::Login
|
|||||||
env.redirect referer
|
env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Validates and displays captchas to the end user
|
||||||
def self.captcha(env)
|
def self.captcha(env)
|
||||||
if !CONFIG.captcha_enabled
|
if !CONFIG.captcha_enabled
|
||||||
error_template(403, "Administrator has disabled this endpoint")
|
error_template(403, "Administrator has disabled this endpoint")
|
||||||
@ -178,7 +179,7 @@ module Invidious::Routes::Login
|
|||||||
answer = env.params.body["answer"]?
|
answer = env.params.body["answer"]?
|
||||||
change_type = env.params.body["change_type"]?
|
change_type = env.params.body["change_type"]?
|
||||||
|
|
||||||
# User requests to change captcha
|
# User requests to change captcha displayed
|
||||||
if !captcha_type || change_type
|
if !captcha_type || change_type
|
||||||
LOGGER.trace("User requests to change Captcha")
|
LOGGER.trace("User requests to change Captcha")
|
||||||
|
|
||||||
@ -190,8 +191,11 @@ module Invidious::Routes::Login
|
|||||||
|
|
||||||
tokens = env.params.body.select { |k, _| k.match(/^token\[\d+\]$/) }.map { |_, v| v }
|
tokens = env.params.body.select { |k, _| k.match(/^token\[\d+\]$/) }.map { |_, v| v }
|
||||||
|
|
||||||
|
# Captcha validation
|
||||||
|
|
||||||
answer ||= ""
|
answer ||= ""
|
||||||
captcha_type ||= "image"
|
captcha_type ||= "image"
|
||||||
|
|
||||||
case captcha_type
|
case captcha_type
|
||||||
when "image"
|
when "image"
|
||||||
answer = answer.lstrip('0')
|
answer = answer.lstrip('0')
|
||||||
@ -225,6 +229,8 @@ module Invidious::Routes::Login
|
|||||||
env.redirect referer
|
env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Private method to register an user within a database after
|
||||||
|
# validation
|
||||||
private def self.register_user(env, email, password)
|
private def self.register_user(env, email, password)
|
||||||
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
||||||
user, sid = create_user(sid, email, password)
|
user, sid = create_user(sid, email, password)
|
||||||
|
Loading…
Reference in New Issue
Block a user