mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
downcase usernames
This commit is contained in:
parent
3c665f6082
commit
7c9f1511bf
1 changed files with 8 additions and 4 deletions
|
@ -7,7 +7,7 @@ class Site < Sequel::Model
|
||||||
USERNAME_REGEX = /[^\w-]/i
|
USERNAME_REGEX = /[^\w-]/i
|
||||||
many_to_one :server
|
many_to_one :server
|
||||||
many_to_many :tags
|
many_to_many :tags
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def valid_login?(username, plaintext)
|
def valid_login?(username, plaintext)
|
||||||
site = self[username: username]
|
site = self[username: username]
|
||||||
|
@ -23,7 +23,11 @@ class Site < Sequel::Model
|
||||||
@bcrypt_cost = cost
|
@bcrypt_cost = cost
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def username=(val)
|
||||||
|
super val.downcase
|
||||||
|
end
|
||||||
|
|
||||||
def valid_password?(plaintext)
|
def valid_password?(plaintext)
|
||||||
BCrypt::Password.new(values[:password]) == plaintext
|
BCrypt::Password.new(values[:password]) == plaintext
|
||||||
end
|
end
|
||||||
|
@ -78,7 +82,7 @@ class Site < Sequel::Model
|
||||||
errors.add :password, "Password must be at least #{MINIMUM_PASSWORD_LENGTH} characters."
|
errors.add :password, "Password must be at least #{MINIMUM_PASSWORD_LENGTH} characters."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_list
|
def file_list
|
||||||
Dir.glob(File.join(DIR_ROOT, 'public', 'sites', username, '*')).collect {|p| File.basename(p)}.sort.collect {|sitename| SiteFile.new sitename}
|
Dir.glob(File.join(DIR_ROOT, 'public', 'sites', username, '*')).collect {|p| File.basename(p)}.sort.collect {|sitename| SiteFile.new sitename}
|
||||||
end
|
end
|
||||||
|
@ -92,4 +96,4 @@ class Site < Sequel::Model
|
||||||
remaining = MAX_SPACE - total_space
|
remaining = MAX_SPACE - total_space
|
||||||
remaining < 0 ? 0 : remaining
|
remaining < 0 ? 0 : remaining
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue