From db561d99b5c00360309c81536b9a3ab337845218 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Wed, 1 Feb 2023 11:17:18 +0100 Subject: [PATCH] Crystal bindings: authd: no need for events in 'handle' methods. --- zig-impl/crystal/some-crystal-app/authd/requests/admin.cr | 4 ++-- zig-impl/crystal/some-crystal-app/authd/requests/contact.cr | 4 ++-- zig-impl/crystal/some-crystal-app/authd/requests/delete.cr | 2 +- zig-impl/crystal/some-crystal-app/authd/requests/list.cr | 2 +- .../crystal/some-crystal-app/authd/requests/password.cr | 6 +++--- .../crystal/some-crystal-app/authd/requests/permissions.cr | 4 ++-- zig-impl/crystal/some-crystal-app/authd/requests/profile.cr | 4 ++-- .../crystal/some-crystal-app/authd/requests/register.cr | 2 +- zig-impl/crystal/some-crystal-app/authd/requests/search.cr | 2 +- zig-impl/crystal/some-crystal-app/authd/requests/token.cr | 2 +- zig-impl/crystal/some-crystal-app/authd/requests/users.cr | 6 +++--- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/admin.cr b/zig-impl/crystal/some-crystal-app/authd/requests/admin.cr index 8ff4e54..c8a0985 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/admin.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/admin.cr @@ -13,7 +13,7 @@ class AuthD::Request def initialize(@shared_key, @login, @password, @email, @phone, @profile) 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 mail address verification. if @shared_key != authd.configuration.shared_key @@ -63,7 +63,7 @@ class AuthD::Request def initialize(@shared_key, @user) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) if @shared_key != authd.configuration.shared_key return Response::Error.new "invalid authentication key" end diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/contact.cr b/zig-impl/crystal/some-crystal-app/authd/requests/contact.cr index 5149ebc..4ab83fb 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/contact.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/contact.cr @@ -8,7 +8,7 @@ class AuthD::Request def initialize(@token) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.get_user_from_token @token return Response::Error.new "invalid user" unless user @@ -32,7 +32,7 @@ class AuthD::Request def initialize(@token) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.get_user_from_token @token return Response::Error.new "invalid user" unless user diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/delete.cr b/zig-impl/crystal/some-crystal-app/authd/requests/delete.cr index e2e30ad..a1e58c6 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/delete.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/delete.cr @@ -13,7 +13,7 @@ class AuthD::Request def initialize(@user, @shared_key) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) uid_or_login = @user user_to_delete = if uid_or_login.is_a? Int32 authd.users_per_uid.get? uid_or_login.to_s diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/list.cr b/zig-impl/crystal/some-crystal-app/authd/requests/list.cr index edd05d1..6f52d92 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/list.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/list.cr @@ -6,7 +6,7 @@ class AuthD::Request def initialize(@token, @key) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) # FIXME: Lines too long, repeatedly (>80c with 4c tabs). @token.try do |token| user = authd.get_user_from_token token diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/password.cr b/zig-impl/crystal/some-crystal-app/authd/requests/password.cr index 646f469..5b545f6 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/password.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/password.cr @@ -7,7 +7,7 @@ class AuthD::Request def initialize(@login, @old_password, @new_password) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.users_per_login.get? @login unless user @@ -35,7 +35,7 @@ class AuthD::Request def initialize(@user, @password_renew_key, @new_password) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) uid_or_login = @user user = if uid_or_login.is_a? Int32 authd.users_per_uid.get? uid_or_login.to_s @@ -69,7 +69,7 @@ class AuthD::Request def initialize(@user, @email) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) uid_or_login = @user user = if uid_or_login.is_a? Int32 authd.users_per_uid.get? uid_or_login.to_s diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/permissions.cr b/zig-impl/crystal/some-crystal-app/authd/requests/permissions.cr index fdc2b6c..48cf7b5 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/permissions.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/permissions.cr @@ -10,7 +10,7 @@ class AuthD::Request def initialize(@shared_key, @user, @service, @resource) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) authorized = false if key = @shared_key @@ -79,7 +79,7 @@ class AuthD::Request def initialize(@shared_key, @user, @service, @resource, @permission) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) unless @shared_key == authd.configuration.shared_key return Response::Error.new "unauthorized" end diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/profile.cr b/zig-impl/crystal/some-crystal-app/authd/requests/profile.cr index daa2a16..306987a 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/profile.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/profile.cr @@ -6,7 +6,7 @@ class AuthD::Request def initialize(@token, @new_profile) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.get_user_from_token @token return Response::Error.new "invalid user" unless user @@ -45,7 +45,7 @@ class AuthD::Request def initialize(@token, @new_profile) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = if token = @token u = authd.get_user_from_token token raise UserNotFound.new unless u diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/register.cr b/zig-impl/crystal/some-crystal-app/authd/requests/register.cr index 8407174..9c23982 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/register.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/register.cr @@ -9,7 +9,7 @@ class AuthD::Request def initialize(@login, @password, @email, @phone, @profile) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) if ! authd.configuration.registrations return Response::Error.new "registrations not allowed" end diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/search.cr b/zig-impl/crystal/some-crystal-app/authd/requests/search.cr index b42f3b6..239ab47 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/search.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/search.cr @@ -5,7 +5,7 @@ class AuthD::Request def initialize(@user) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) pattern = Regex.new @user, Regex::Options::IGNORE_CASE matching_users = Array(AuthD::User::Public).new diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/token.cr b/zig-impl/crystal/some-crystal-app/authd/requests/token.cr index 6749285..94f8462 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/token.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/token.cr @@ -6,7 +6,7 @@ class AuthD::Request def initialize(@login, @password) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) begin user = authd.users_per_login.get @login rescue e : DODB::MissingEntry diff --git a/zig-impl/crystal/some-crystal-app/authd/requests/users.cr b/zig-impl/crystal/some-crystal-app/authd/requests/users.cr index 0bf573b..edf6b91 100644 --- a/zig-impl/crystal/some-crystal-app/authd/requests/users.cr +++ b/zig-impl/crystal/some-crystal-app/authd/requests/users.cr @@ -6,7 +6,7 @@ class AuthD::Request def initialize(@login, @activation_key) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.users_per_login.get? @login if user.nil? @@ -37,7 +37,7 @@ class AuthD::Request def initialize(@user) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) uid_or_login = @user user = if uid_or_login.is_a? Int32 authd.users_per_uid.get? uid_or_login.to_s @@ -61,7 +61,7 @@ class AuthD::Request def initialize(@login, @password) end - def handle(authd : AuthD::Service, event : IPC::Event::Events) + def handle(authd : AuthD::Service) user = authd.users_per_login.get? @login unless user