From bbf7a9a80ed16aa26617a63e3634c8da17daed07 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Fri, 14 Jun 2024 16:16:56 +0200 Subject: [PATCH] tmp --- makefile | 2 +- src/client.cr | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index d9c1328..f3c4de8 100644 --- a/makefile +++ b/makefile @@ -52,7 +52,7 @@ get-user: migrate-user: ./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT) -USER_DB ?= user-db.txt +USER_DB ?= /tmp/authd-migration-user-db.txt migrate-all-users: ./bin/authc migration-script $(USER_DB) $(LOGIN_OPT) diff --git a/src/client.cr b/src/client.cr index 74f0a9f..68c23e5 100644 --- a/src/client.cr +++ b/src/client.cr @@ -112,8 +112,23 @@ class Actions File.each_line(filename) do |line| login, password_hash_brkn = line.split("\t") - Baguette::Log.info "adding user '#{login}', hash '#{password_hash_brkn}'" - pp! authd.migrate_user login, password_hash_brkn + STDOUT.write ((" " * 150) + "\r").to_slice + STDOUT.write "adding user '#{login}'\r".to_slice + response = authd.migrate_user login, password_hash_brkn + + case response + when AuthD::Response::UserAdded + pp! response.user + when AuthD::Response::ErrorMustBeAuthenticated + Baguette::Log.error "ErrorMustBeAuthenticated" + exit 1 + when AuthD::Response::ErrorAlreadyUsedLogin + #Baguette::Log.error "ErrorAlreadyUsedLogin" + when AuthD::Response::ErrorMailRequired + Baguette::Log.error "ErrorMailRequired" + else + Baguette::Log.error "unknown error" + end end rescue e : AuthD::Exception