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,11 +7,13 @@
<%= @message %> <%= @message %>
<% if @error %><p><%= @error %></p><% end %> <% if @error %><p><%= @error %></p><% end %>
<% if @second_factor_required %>
<%=form_tag({}, method: :put) do %> <%=form_tag({}, method: :put) do %>
<%= label_tag(:second_factor_token, t('login.second_factor_description')) %> <%= label_tag(:second_factor_token, t('login.second_factor_description')) %>
<%= text_field_tag(:second_factor_token, nil, autofocus: true) %><br><br> <%= text_field_tag(:second_factor_token, nil, autofocus: true) %><br><br>
<%= submit_tag t('submit')%> <%= submit_tag t('submit')%>
<% end %> <% end %>
<% end %>
<% else %> <% else %>
<%=form_tag({}, method: :put) do %> <%=form_tag({}, method: :put) do %>
<%= label_tag(:email, t('admin_login.email_input')) %> <%= label_tag(:email, t('admin_login.email_input')) %>

View File

@ -523,6 +523,21 @@ describe UsersController do
end end
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 context 'logs in admin' do
it 'does not log in admin with invalid token' do it 'does not log in admin with invalid token' do
SiteSetting.sso_url = "https://www.example.com/sso" SiteSetting.sso_url = "https://www.example.com/sso"