Email editing WIP.

This commit is contained in:
Luka Vandervelden 2020-08-27 18:14:44 +02:00
parent bd9c196cc6
commit 030f6cf1ba
2 changed files with 21 additions and 0 deletions

View File

@ -339,6 +339,13 @@ class AuthD::Request
initialize :token, :new_profile
end
class EditContacts < Request
property token : String
property email : String?
property phone : String?
end
# This creates a Request::Type enumeration. One entry for each request type.
{% begin %}
enum Type

View File

@ -508,6 +508,20 @@ class AuthD::Service
@users_per_uid.update user.uid.to_s, user
Response::User.new user.to_public
when Request::EditContacts
user = get_user_from_token request.token
return Response::Error.new "invalid user" unless user
if email = request.email
# FIXME: This *should* require checking the new mail, with
# a new activation key and everything else.
user.contact.email = email
end
@users_per_uid.update user
Response::UserEdited.new user.uid
else
Response::Error.new "unhandled request type"
end