Skip to content

Commit

Permalink
Add guide on customizing email requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Dec 10, 2024
1 parent c85e485 commit 830148b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions doc/guides/email_requirements.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
= Customize email requirements

By default, Rodauth requires emails to have at least 3 characters and at most
255 bytes. You can modify the minimum and maximum length:

plugin :rodauth do
enable :login, :logout, :create_account

# Require emails to have at least 5 characters
login_minimum_length 5

# Don't allow emails longer than 100 characters
login_maximum_length 100

# Don't allow emails larger than 200 bytes
login_maximum_bytes 200
end

You can also override email address validation, and do more advanced email
checks, such as checking whether the email address exists using the
{Truemail}[https://github.com/truemail-rb/truemail] gem:

require "truemail"

Truemail.configure do |config|
config.verifier_email = "verifier@example.com"
end

plugin :rodauth do
enable :login, :logout, :create_account

login_valid_email? do |email|
super(email) && Truemail.valid?(email)
end
end
1 change: 1 addition & 0 deletions www/pages/documentation.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<li><a href="rdoc/files/doc/guides/create_account_programmatically_rdoc.html">Create an account record programmatically</a></li>
<li><a href="rdoc/files/doc/guides/delay_password_rdoc.html">Set password when verifying account</a></li>
<li><a href="rdoc/files/doc/guides/email_only_rdoc.html">Allow only email authentication</a></li>
<li><a href="rdoc/files/doc/guides/email_requirements_rdoc.html">Customize email requirements</a></li>
<li><a href="rdoc/files/doc/guides/i18n_rdoc.html">Translate with I18n gem</a></li>
<li><a href="rdoc/files/doc/guides/links_rdoc.html">Display authentication links</a></li>
<li><a href="rdoc/files/doc/guides/login_return_rdoc.html">Redirect to original page after login</a></li>
Expand Down

0 comments on commit 830148b

Please sign in to comment.