mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
no hyphens at start or end of username
This commit is contained in:
parent
afb1d756e0
commit
837b0ea2d0
1 changed files with 2 additions and 2 deletions
|
@ -658,7 +658,7 @@ class Site < Sequel::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.valid_username?(username)
|
def self.valid_username?(username)
|
||||||
!username.empty? && username.match(/^[a-zA-Z0-9_\-]+$/i)
|
!username.empty? && username.match(/^[a-zA-Z0-9][a-zA-Z0-9_\-]+[a-zA-Z0-9]$/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.disposable_email_domains
|
def self.disposable_email_domains
|
||||||
|
@ -986,7 +986,7 @@ class Site < Sequel::Model
|
||||||
super
|
super
|
||||||
|
|
||||||
if !self.class.valid_username?(values[:username])
|
if !self.class.valid_username?(values[:username])
|
||||||
errors.add :username, 'Usernames can only contain letters, numbers, and hyphens.'
|
errors.add :username, 'Usernames can only contain letters, numbers, and hyphens, and cannot start or end with a hyphen.'
|
||||||
end
|
end
|
||||||
|
|
||||||
if !values[:username].blank?
|
if !values[:username].blank?
|
||||||
|
|
Loading…
Add table
Reference in a new issue