From 030f6cf1bac98585569da156c95e754926ae34d7 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Thu, 27 Aug 2020 18:14:44 +0200 Subject: [PATCH] Email editing WIP. --- src/authd.cr | 7 +++++++ src/main.cr | 14 ++++++++++++++ 2 files changed, 21 insertions(+) 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