mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
fix password change
This commit is contained in:
parent
5403d61ac2
commit
2dd3a34961
2 changed files with 24 additions and 2 deletions
|
@ -210,7 +210,7 @@ class Site < Sequel::Model
|
||||||
def password=(plaintext)
|
def password=(plaintext)
|
||||||
@password_length = plaintext.nil? ? 0 : plaintext.length
|
@password_length = plaintext.nil? ? 0 : plaintext.length
|
||||||
@password_plaintext = plaintext
|
@password_plaintext = plaintext
|
||||||
values[:password] = BCrypt::Password.create plaintext, cost: (self.class.bcrypt_cost || BCrypt::Engine::DEFAULT_COST)
|
super BCrypt::Password.create plaintext, cost: (self.class.bcrypt_cost || BCrypt::Engine::DEFAULT_COST)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_tags_string=(tags_string)
|
def new_tags_string=(tags_string)
|
||||||
|
|
|
@ -87,7 +87,6 @@ describe 'site/settings' do
|
||||||
@domain = SecureRandom.uuid.gsub('-', '')+'.com'
|
@domain = SecureRandom.uuid.gsub('-', '')+'.com'
|
||||||
@site = Fabricate :site, domain: @domain
|
@site = Fabricate :site, domain: @domain
|
||||||
page.set_rack_session id: @site.id
|
page.set_rack_session id: @site.id
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails without domain set' do
|
it 'fails without domain set' do
|
||||||
|
@ -216,4 +215,27 @@ describe 'site/settings' do
|
||||||
Site[username: ''].must_equal nil
|
Site[username: ''].must_equal nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'change password' do
|
||||||
|
include Capybara::DSL
|
||||||
|
|
||||||
|
before do
|
||||||
|
@site = Fabricate :site, password: 'derpie'
|
||||||
|
page.set_rack_session id: @site.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should change correctly' do
|
||||||
|
visit '/settings'
|
||||||
|
|
||||||
|
fill_in 'current_password', with: 'derpie'
|
||||||
|
fill_in 'new_password', with: 'derpie2'
|
||||||
|
fill_in 'new_password_confirm', with: 'derpie2'
|
||||||
|
click_button 'Change Password'
|
||||||
|
|
||||||
|
page.must_have_content /successfully changed password/i
|
||||||
|
@site.reload
|
||||||
|
@site.valid_password?('derpie').must_equal false
|
||||||
|
@site.valid_password?('derpie2').must_equal true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue