aboutsummaryrefslogtreecommitdiff
path: root/src/operations/request_password_reset.cr
diff options
context:
space:
mode:
authorfloppydiskette <floppydisk@hyprcat.net>2024-09-13 12:58:12 +0100
committerfloppydiskette <floppydisk@hyprcat.net>2024-09-13 12:59:16 +0100
commit2c3400fb4f5a22951d42f286975201bf817d7883 (patch)
treea08b06f5f6d5df4f6774da7645d85418609a4cf2 /src/operations/request_password_reset.cr
parentd8915dcca4d9752f6f254e86afa39ef7f83617d1 (diff)
wronglucky
Diffstat (limited to 'src/operations/request_password_reset.cr')
-rw-r--r--src/operations/request_password_reset.cr25
1 files changed, 25 insertions, 0 deletions
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