mirror of
https://github.com/neocities/neocities.git
synced 2025-07-21 18:16:07 +02:00
brush up email requirements
This commit is contained in:
parent
933fb9fcfd
commit
d3fc35989d
10 changed files with 149 additions and 10 deletions
|
@ -358,6 +358,10 @@ class Site < Sequel::Model
|
|||
super
|
||||
end
|
||||
|
||||
def before_create
|
||||
self.email_confirmation_token = SecureRandom.hex 3
|
||||
end
|
||||
|
||||
# def after_destroy
|
||||
# FileUtils.rm_rf file_path
|
||||
# super
|
||||
|
@ -379,6 +383,17 @@ class Site < Sequel::Model
|
|||
errors.add :username, 'User/site name cannot exceed 32 characters.'
|
||||
end
|
||||
|
||||
|
||||
# Check that email has been provided
|
||||
if new? && values[:email].empty?
|
||||
errors.add :email, 'An email address is required.'
|
||||
end
|
||||
|
||||
# Check for existing email
|
||||
if new? && self.class.select(:id).filter(email: values[:email]).first
|
||||
errors.add :email, 'This email address already exists on Neocities, please use your existing account.'
|
||||
end
|
||||
|
||||
# Check for existing user
|
||||
user = self.class.select(:id, :username).filter(username: values[:username]).first
|
||||
|
||||
|
@ -522,7 +537,7 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def host
|
||||
domain ? domain : "#{username}.neocities.org"
|
||||
!domain.empty? ? domain : "#{username}.neocities.org"
|
||||
end
|
||||
|
||||
def title
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue