mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-28 15:38:30 +00:00
Update authentication.cr
This commit is contained in:
parent
96edb37f5b
commit
3a4890edc3
@ -11,11 +11,11 @@ module Invidious::Routes::API::V1::Authentication
|
|||||||
creds = nil
|
creds = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
# begin
|
||||||
captcha_response = CaptchaResponse.from_json(env.request.body || "{}")
|
# captcha_response = CaptchaResponse.from_json(env.request.body || "{}")
|
||||||
rescue JSON::SerializableError
|
# rescue JSON::SerializableError
|
||||||
captcha_response = nil
|
# captcha_response = nil
|
||||||
end
|
# end
|
||||||
|
|
||||||
if creds
|
if creds
|
||||||
# user is registering
|
# user is registering
|
||||||
@ -38,17 +38,17 @@ module Invidious::Routes::API::V1::Authentication
|
|||||||
return captcha
|
return captcha
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if captcha_response
|
# if captcha_response
|
||||||
# process captcha response
|
# # process captcha response
|
||||||
answer = captcha_response.answer
|
# answer = captcha_response.answer
|
||||||
answer = answer.lstrip('0')
|
# answer = answer.lstrip('0')
|
||||||
answer = OpenSSL::HMAC.hexdigest(:sha256, HMAC_KEY, answer)
|
# answer = OpenSSL::HMAC.hexdigest(:sha256, HMAC_KEY, answer)
|
||||||
begin
|
# begin
|
||||||
validate_request(tokens[0], answer, env.request, HMAC_KEY, locale)
|
# validate_request(, answer, env.request, HMAC_KEY, locale)
|
||||||
rescue ex
|
# rescue ex
|
||||||
return error_jsonror(400, ex)
|
# return error_jsonror(400, ex)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
# create user if we made it past credentials and captcha
|
# create user if we made it past credentials and captcha
|
||||||
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)
|
||||||
@ -119,6 +119,7 @@ struct CaptchaResponse
|
|||||||
include YAML::Serializable
|
include YAML::Serializable
|
||||||
|
|
||||||
property answer : String
|
property answer : String
|
||||||
|
property tokens : Array()
|
||||||
end
|
end
|
||||||
|
|
||||||
struct Credentials
|
struct Credentials
|
||||||
|
Loading…
Reference in New Issue
Block a user