From 2c3400fb4f5a22951d42f286975201bf817d7883 Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Fri, 13 Sep 2024 12:58:12 +0100 Subject: wrong --- src/operations/request_password_reset.cr | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/operations/request_password_reset.cr (limited to 'src/operations/request_password_reset.cr') diff --git a/src/operations/request_password_reset.cr b/src/operations/request_password_reset.cr new file mode 100644 index 0000000..4941aa7 --- /dev/null +++ b/src/operations/request_password_reset.cr @@ -0,0 +1,25 @@ +class RequestPasswordReset < Avram::Operation + # You can modify this in src/operations/mixins/user_from_email.cr + include UserFromEmail + + attribute email : String + + # Run validations and yield the operation and the user if valid + def run + user = user_from_email + validate(user) + + if valid? + user + else + nil + end + end + + def validate(user : User?) + validate_required email + if user.nil? + email.add_error "is not in our system" + end + end +end -- cgit v1.2.3-54-g00ecf