dnsmanager/src/client/lib/authd_api.cr

17 lines
410 B
Crystal

def authd_get_token(login : String? = nil, pass : String? = nil)
authd = AuthD::Client.new
response = authd.login? login, pass
case response
when Response::Login
authd.close
uid = response.uid
token = response.token
Baguette::Log.info "Authenticated as #{login} #{uid}, token: #{token}"
return token
end
authd.close
raise "Cannot authenticate to authd with login #{login}: #{response}."
end