44 lines
1.1 KiB
Crystal
44 lines
1.1 KiB
Crystal
class AuthD::Request
|
|
IPC::JSON.message EditContacts, 16 do
|
|
property email : String? = nil
|
|
property phone : String? = nil
|
|
|
|
def initialize(@email, @phone)
|
|
end
|
|
|
|
def handle(authd : AuthD::Service, fd : Int32)
|
|
logged_user = authd.get_logged_user_full? fd
|
|
return Response::Error.new "you must be logged" if logged_user.nil?
|
|
|
|
if email = @email
|
|
# FIXME: This *should* require checking the new mail, with
|
|
# a new activation key and everything else.
|
|
logged_user.contact.email = email
|
|
end
|
|
|
|
if phone = @phone
|
|
logged_user.contact.phone = phone
|
|
end
|
|
|
|
authd.users_per_uid.update logged_user
|
|
|
|
Response::UserEdited.new logged_user.uid
|
|
end
|
|
end
|
|
AuthD.requests << EditContacts
|
|
|
|
IPC::JSON.message GetContacts, 18 do
|
|
def initialize()
|
|
end
|
|
|
|
def handle(authd : AuthD::Service, fd : Int32)
|
|
logged_user = authd.get_logged_user_full? fd
|
|
return Response::Error.new "you must be logged" if logged_user.nil?
|
|
|
|
_c = logged_user.contact
|
|
Response::Contacts.new logged_user.uid, _c.email, _c.phone
|
|
end
|
|
end
|
|
AuthD.requests << GetContacts
|
|
end
|