diff --git a/src/authd.cr b/src/authd.cr index 23986e5..31111fc 100644 --- a/src/authd.cr +++ b/src/authd.cr @@ -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 diff --git a/src/main.cr b/src/main.cr index 0d09980..a2e8f73 100644 --- a/src/main.cr +++ b/src/main.cr @@ -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