Use standard Devise sessions controller in admin area

Fixes a bug when retrying to login with correct credentials
This commit is contained in:
Artur Beljajev 2018-07-18 20:02:05 +03:00
parent a2451f4a13
commit 5561825584
8 changed files with 88 additions and 47 deletions

View file

@ -0,0 +1,29 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br/>
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br/>
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' &&
controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br/>
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
<br/>
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) &&
controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br/>
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}",
omniauth_authorize_path(resource_name, provider) %><br/>
<% end -%>
<% end -%>

View file

@ -1,15 +0,0 @@
.row
.form-signin.col-md-6.center-block.text-center
%h2.form-signin-heading.text-center Eesti Interneti SA
%hr
.form-signin
= form_for(@admin_user, url: admin_user_session_path, html: {class: 'form-signin'}) do |f|
= render 'admin/shared/errors', object: f.object
- error_class = f.object.errors.any? ? 'has-error' : ''
%div{class: error_class}
= f.text_field :username, class: 'form-control', placeholder: t(:username), required: true
= f.password_field :password, class: 'form-control',
autocomplete: 'off', placeholder: t(:password), required: true
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)

View file

@ -0,0 +1,30 @@
<div class="row">
<%= form_for resource, as: resource_name, url: session_path(resource_name),
html: { class: 'col-md-6 form-signin center-block text-center' } do |f| %>
<h2 class="form-signin-heading text-center">Eesti Interneti SA</h2>
<hr>
<%= f.label :username, class: 'sr-only' %>
<%= f.text_field :username, placeholder: AdminUser.human_attribute_name(:username),
required: true,
autofocus: true,
class: 'form-control' %>
<%= f.label :password, class: 'sr-only' %>
<%= f.password_field :password, placeholder: AdminUser.human_attribute_name(:password),
required: true,
autocomplete: 'off',
class: 'form-control' %>
<% if devise_mapping.rememberable? -%>
<div class="checkbox">
<label><%= f.check_box :remember_me %> <%= t '.remember_checkbox' %> %></label>
</div>
<% end -%>
<%= f.submit t('.sign_in_btn'), class: 'btn btn-lg btn-primary btn-block' %>
<% end %>
</div>
<%= render 'links' %>