Archived
3
0

Crystal bindings: authd: no need for events in 'handle' methods.

This commit is contained in:
Philippe Pittoli 2023-02-01 11:17:18 +01:00
parent 79752068c6
commit db561d99b5
11 changed files with 19 additions and 19 deletions

View File

@ -13,7 +13,7 @@ class AuthD::Request
def initialize(@shared_key, @login, @password, @email, @phone, @profile) def initialize(@shared_key, @login, @password, @email, @phone, @profile)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
# No verification of the users' informations when an admin adds it. # No verification of the users' informations when an admin adds it.
# No mail address verification. # No mail address verification.
if @shared_key != authd.configuration.shared_key if @shared_key != authd.configuration.shared_key
@ -63,7 +63,7 @@ class AuthD::Request
def initialize(@shared_key, @user) def initialize(@shared_key, @user)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
if @shared_key != authd.configuration.shared_key if @shared_key != authd.configuration.shared_key
return Response::Error.new "invalid authentication key" return Response::Error.new "invalid authentication key"
end end

View File

@ -8,7 +8,7 @@ class AuthD::Request
def initialize(@token) def initialize(@token)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.get_user_from_token @token user = authd.get_user_from_token @token
return Response::Error.new "invalid user" unless user return Response::Error.new "invalid user" unless user
@ -32,7 +32,7 @@ class AuthD::Request
def initialize(@token) def initialize(@token)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.get_user_from_token @token user = authd.get_user_from_token @token
return Response::Error.new "invalid user" unless user return Response::Error.new "invalid user" unless user

View File

@ -13,7 +13,7 @@ class AuthD::Request
def initialize(@user, @shared_key) def initialize(@user, @shared_key)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
uid_or_login = @user uid_or_login = @user
user_to_delete = if uid_or_login.is_a? Int32 user_to_delete = if uid_or_login.is_a? Int32
authd.users_per_uid.get? uid_or_login.to_s authd.users_per_uid.get? uid_or_login.to_s

View File

@ -6,7 +6,7 @@ class AuthD::Request
def initialize(@token, @key) def initialize(@token, @key)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
# FIXME: Lines too long, repeatedly (>80c with 4c tabs). # FIXME: Lines too long, repeatedly (>80c with 4c tabs).
@token.try do |token| @token.try do |token|
user = authd.get_user_from_token token user = authd.get_user_from_token token

View File

@ -7,7 +7,7 @@ class AuthD::Request
def initialize(@login, @old_password, @new_password) def initialize(@login, @old_password, @new_password)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.users_per_login.get? @login user = authd.users_per_login.get? @login
unless user unless user
@ -35,7 +35,7 @@ class AuthD::Request
def initialize(@user, @password_renew_key, @new_password) def initialize(@user, @password_renew_key, @new_password)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
uid_or_login = @user uid_or_login = @user
user = if uid_or_login.is_a? Int32 user = if uid_or_login.is_a? Int32
authd.users_per_uid.get? uid_or_login.to_s authd.users_per_uid.get? uid_or_login.to_s
@ -69,7 +69,7 @@ class AuthD::Request
def initialize(@user, @email) def initialize(@user, @email)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
uid_or_login = @user uid_or_login = @user
user = if uid_or_login.is_a? Int32 user = if uid_or_login.is_a? Int32
authd.users_per_uid.get? uid_or_login.to_s authd.users_per_uid.get? uid_or_login.to_s

View File

@ -10,7 +10,7 @@ class AuthD::Request
def initialize(@shared_key, @user, @service, @resource) def initialize(@shared_key, @user, @service, @resource)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
authorized = false authorized = false
if key = @shared_key if key = @shared_key
@ -79,7 +79,7 @@ class AuthD::Request
def initialize(@shared_key, @user, @service, @resource, @permission) def initialize(@shared_key, @user, @service, @resource, @permission)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
unless @shared_key == authd.configuration.shared_key unless @shared_key == authd.configuration.shared_key
return Response::Error.new "unauthorized" return Response::Error.new "unauthorized"
end end

View File

@ -6,7 +6,7 @@ class AuthD::Request
def initialize(@token, @new_profile) def initialize(@token, @new_profile)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.get_user_from_token @token user = authd.get_user_from_token @token
return Response::Error.new "invalid user" unless user return Response::Error.new "invalid user" unless user
@ -45,7 +45,7 @@ class AuthD::Request
def initialize(@token, @new_profile) def initialize(@token, @new_profile)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = if token = @token user = if token = @token
u = authd.get_user_from_token token u = authd.get_user_from_token token
raise UserNotFound.new unless u raise UserNotFound.new unless u

View File

@ -9,7 +9,7 @@ class AuthD::Request
def initialize(@login, @password, @email, @phone, @profile) def initialize(@login, @password, @email, @phone, @profile)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
if ! authd.configuration.registrations if ! authd.configuration.registrations
return Response::Error.new "registrations not allowed" return Response::Error.new "registrations not allowed"
end end

View File

@ -5,7 +5,7 @@ class AuthD::Request
def initialize(@user) def initialize(@user)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
pattern = Regex.new @user, Regex::Options::IGNORE_CASE pattern = Regex.new @user, Regex::Options::IGNORE_CASE
matching_users = Array(AuthD::User::Public).new matching_users = Array(AuthD::User::Public).new

View File

@ -6,7 +6,7 @@ class AuthD::Request
def initialize(@login, @password) def initialize(@login, @password)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
begin begin
user = authd.users_per_login.get @login user = authd.users_per_login.get @login
rescue e : DODB::MissingEntry rescue e : DODB::MissingEntry

View File

@ -6,7 +6,7 @@ class AuthD::Request
def initialize(@login, @activation_key) def initialize(@login, @activation_key)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.users_per_login.get? @login user = authd.users_per_login.get? @login
if user.nil? if user.nil?
@ -37,7 +37,7 @@ class AuthD::Request
def initialize(@user) def initialize(@user)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
uid_or_login = @user uid_or_login = @user
user = if uid_or_login.is_a? Int32 user = if uid_or_login.is_a? Int32
authd.users_per_uid.get? uid_or_login.to_s authd.users_per_uid.get? uid_or_login.to_s
@ -61,7 +61,7 @@ class AuthD::Request
def initialize(@login, @password) def initialize(@login, @password)
end end
def handle(authd : AuthD::Service, event : IPC::Event::Events) def handle(authd : AuthD::Service)
user = authd.users_per_login.get? @login user = authd.users_per_login.get? @login
unless user unless user