Fixes #3189 - Unable to create inital admin user via web installer
This commit is contained in:
parent
1a42d9ada3
commit
138edc437b
7 changed files with 51 additions and 18 deletions
|
@ -238,10 +238,7 @@ class Admin extends App.WizardFullScreen
|
||||||
|
|
||||||
fail: (settings, details) =>
|
fail: (settings, details) =>
|
||||||
@formEnable(e)
|
@formEnable(e)
|
||||||
if _.isArray(details.error)
|
@form.showAlert(details.error_human || details.error || 'Unable to create user!')
|
||||||
@form.showAlert( App.i18n.translateInline( details.error[0], details.error[1] ) )
|
|
||||||
else
|
|
||||||
@form.showAlert(details.error_human || details.error || 'Unable to create user!')
|
|
||||||
)
|
)
|
||||||
|
|
||||||
relogin: (data, status, xhr) =>
|
relogin: (data, status, xhr) =>
|
||||||
|
@ -965,7 +962,7 @@ class Agent extends App.WizardFullScreen
|
||||||
|
|
||||||
@html App.view('getting_started/agent')()
|
@html App.view('getting_started/agent')()
|
||||||
|
|
||||||
new App.ControllerForm(
|
@form = new App.ControllerForm(
|
||||||
el: @$('.js-agent-form')
|
el: @$('.js-agent-form')
|
||||||
model: App.User
|
model: App.User
|
||||||
screen: 'invite_agent'
|
screen: 'invite_agent'
|
||||||
|
@ -1012,11 +1009,7 @@ class Agent extends App.WizardFullScreen
|
||||||
|
|
||||||
fail: (settings, details) =>
|
fail: (settings, details) =>
|
||||||
@formEnable(e)
|
@formEnable(e)
|
||||||
App.Event.trigger 'notify', {
|
@form.showAlert details.error_human || 'Can\'t create user!'
|
||||||
type: 'error'
|
|
||||||
msg: App.i18n.translateContent(details.error_human || 'Can\'t create user!')
|
|
||||||
timeout: 2500
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set('getting_started/agents', Agent, 'Routes')
|
App.Config.set('getting_started/agents', Agent, 'Routes')
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Index extends App.ControllerContent
|
||||||
)
|
)
|
||||||
fail: (settings, details) =>
|
fail: (settings, details) =>
|
||||||
@formEnable(e)
|
@formEnable(e)
|
||||||
@form.showAlert(details.error_human || details.error || 'Unable to update object!')
|
@form.showAlert(details.error_human || details.error || 'Unable to create user!')
|
||||||
)
|
)
|
||||||
|
|
||||||
resend: (e) =>
|
resend: (e) =>
|
||||||
|
|
|
@ -968,7 +968,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
|
|
||||||
result = PasswordPolicy.new(clean_user_params[:password])
|
result = PasswordPolicy.new(clean_user_params[:password])
|
||||||
if !result.valid?
|
if !result.valid?
|
||||||
raise Exceptions::UnprocessableEntity, result.error
|
render json: { error: result.error }, status: :unprocessable_entity
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
user = User.new(clean_user_params)
|
user = User.new(clean_user_params)
|
||||||
|
@ -1026,7 +1027,8 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
|
||||||
# check password policy
|
# check password policy
|
||||||
result = PasswordPolicy.new(clean_user_params[:password])
|
result = PasswordPolicy.new(clean_user_params[:password])
|
||||||
if !result.valid?
|
if !result.valid?
|
||||||
raise Exceptions::UnprocessableEntity, result.error
|
render json: { error: result.error }, status: :unprocessable_entity
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
user = User.new(clean_user_params)
|
user = User.new(clean_user_params)
|
||||||
|
|
|
@ -168,8 +168,7 @@ RSpec.describe 'User', type: :request do
|
||||||
params = { email: 'some_new_customer@example.com', password: 'asdasdasdasd', signup: true }
|
params = { email: 'some_new_customer@example.com', password: 'asdasdasdasd', signup: true }
|
||||||
post '/api/v1/users', params: params, headers: headers, as: :json
|
post '/api/v1/users', params: params, headers: headers, as: :json
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
expect(json_response['error']).to be_truthy
|
expect(json_response['error']).to be_a(Array).and(include(match(/Invalid password/)))
|
||||||
expect(json_response['error']).to include('Invalid password')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'verified with no current user', authenticated_as: :admin do
|
it 'verified with no current user', authenticated_as: :admin do
|
||||||
|
|
19
spec/system/getting_started/admin_spec.rb
Normal file
19
spec/system/getting_started/admin_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Getting Started > Admin', type: :system, authenticated_as: false, set_up: false do
|
||||||
|
it 'shows password strength error' do
|
||||||
|
visit 'getting_started/admin'
|
||||||
|
|
||||||
|
fill_in 'firstname', with: 'Test'
|
||||||
|
fill_in 'lastname', with: 'Test'
|
||||||
|
fill_in 'email', with: 'test@example.com'
|
||||||
|
fill_in 'password', with: 'asdasdasdasd'
|
||||||
|
fill_in 'password_confirm', with: 'asdasdasdasd'
|
||||||
|
|
||||||
|
click '.btn--success'
|
||||||
|
|
||||||
|
within '.js-danger' do
|
||||||
|
expect(page).to have_text('Invalid password,').and(have_no_text('["'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
18
spec/system/getting_started/agents_spec.rb
Normal file
18
spec/system/getting_started/agents_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Getting Started > Agents', type: :system do
|
||||||
|
it 'shows password strength error' do
|
||||||
|
visit 'getting_started/agents'
|
||||||
|
|
||||||
|
fill_in 'firstname', with: 'Test'
|
||||||
|
fill_in 'lastname', with: 'Test'
|
||||||
|
fill_in 'email', with: 'master@example.com'
|
||||||
|
|
||||||
|
click '.btn--success'
|
||||||
|
|
||||||
|
within '.js-danger' do
|
||||||
|
expect(page)
|
||||||
|
.to have_text("Email address 'master@example.com' is already used for other user.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,11 +7,13 @@ RSpec.describe 'Signup', type: :system, authenticated_as: false do
|
||||||
fill_in 'firstname', with: 'Test'
|
fill_in 'firstname', with: 'Test'
|
||||||
fill_in 'lastname', with: 'Test'
|
fill_in 'lastname', with: 'Test'
|
||||||
fill_in 'email', with: 'test@example.com'
|
fill_in 'email', with: 'test@example.com'
|
||||||
fill_in 'password', with: 'badpw'
|
fill_in 'password', with: 'asdasdasdasd'
|
||||||
fill_in 'password_confirm', with: 'badpw'
|
fill_in 'password_confirm', with: 'asdasdasdasd'
|
||||||
|
|
||||||
click '.js-submit'
|
click '.js-submit'
|
||||||
|
|
||||||
expect(page).to have_text 'Invalid password,'
|
within '.js-danger' do
|
||||||
|
expect(page).to have_text('Invalid password,').and(have_no_text('["'))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue