FIX: 2FA prompt incorrectly displayed on admin login page.

This commit is contained in:
Guo Xiang Tan 2018-02-23 11:05:39 +08:00
parent 3637f0d3bb
commit 1f74509a75
2 changed files with 21 additions and 4 deletions

View File

@ -7,10 +7,12 @@
<%= @message %>
<% if @error %><p><%= @error %></p><% end %>
<%=form_tag({}, method: :put) do %>
<%= label_tag(:second_factor_token, t('login.second_factor_description')) %>
<%= text_field_tag(:second_factor_token, nil, autofocus: true) %><br><br>
<%= submit_tag t('submit')%>
<% if @second_factor_required %>
<%=form_tag({}, method: :put) do %>
<%= label_tag(:second_factor_token, t('login.second_factor_description')) %>
<%= text_field_tag(:second_factor_token, nil, autofocus: true) %><br><br>
<%= submit_tag t('submit')%>
<% end %>
<% end %>
<% else %>
<%=form_tag({}, method: :put) do %>

View File

@ -523,6 +523,21 @@ describe UsersController do
end
end
context 'when email is incorrect' do
render_views
it 'should return the right response' do
get :admin_login, params: { email: 'random' }
expect(response.status).to eq(200)
response_body = response.body
expect(response_body).to match(I18n.t("admin_login.errors.unknown_email_address"))
expect(response_body).to_not match(I18n.t("login.second_factor_description"))
end
end
context 'logs in admin' do
it 'does not log in admin with invalid token' do
SiteSetting.sso_url = "https://www.example.com/sso"