migration
Philippe PITTOLI 2024-06-14 16:16:56 +02:00
parent ca4cb9e231
commit bbf7a9a80e
2 changed files with 18 additions and 3 deletions

View File

@ -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)

View File

@ -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