IPC.cr API updates.

This commit is contained in:
Luka Vandervelden 2019-06-06 01:16:52 +02:00
parent 8c8b55c7fd
commit 66e2eaad48

View File

@ -72,7 +72,7 @@ module AuthD
initialize "auth"
end
def get_token?(login : String, password : String)
def get_token?(login : String, password : String) : String?
send RequestTypes::GetToken, {
:login => login,
:password => password
@ -81,13 +81,13 @@ module AuthD
response = read
if response.type == ResponseTypes::Ok.value.to_u8
response.payload
String.new response.payload
else
nil
end
end
def get_user?(login : String, password : String)
def get_user?(login : String, password : String) : User?
send RequestTypes::GetUserByCredentials, {
:login => login,
:password => password
@ -96,7 +96,7 @@ module AuthD
response = read
if response.type == ResponseTypes::Ok.value.to_u8
User.from_json response.payload
User.from_json String.new response.payload
else
nil
end
@ -136,11 +136,12 @@ module AuthD
response = read
pp! response.type
payload = String.new response.payload
case ResponseTypes.new response.type.to_i
when ResponseTypes::Ok
AuthD::User.from_json response.payload
AuthD::User.from_json payload
else
Exception.new response.payload
Exception.new payload
end
end
@ -164,7 +165,7 @@ module AuthD
when ResponseTypes::Ok
true
else
Exception.new response.payload
Exception.new String.new response.payload
end
end
end