aboutsummaryrefslogtreecommitdiff
path: root/src/actions/mixins/auth/password_resets/require_token.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions/mixins/auth/password_resets/require_token.cr')
-rw-r--r--src/actions/mixins/auth/password_resets/require_token.cr17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/actions/mixins/auth/password_resets/require_token.cr b/src/actions/mixins/auth/password_resets/require_token.cr
new file mode 100644
index 0000000..15da423
--- /dev/null
+++ b/src/actions/mixins/auth/password_resets/require_token.cr
@@ -0,0 +1,17 @@
+module Auth::PasswordResets::RequireToken
+ macro included
+ before require_valid_password_reset_token
+ end
+
+ abstract def token : String
+ abstract def user : User
+
+ private def require_valid_password_reset_token
+ if Authentic.valid_password_reset_token?(user, token)
+ continue
+ else
+ flash.failure = "The password reset link is incorrect or expired. Please try again."
+ redirect to: PasswordResetRequests::New
+ end
+ end
+end