mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Use standard Devise sessions controller in admin area
Fixes a bug when retrying to login with correct credentials
This commit is contained in:
parent
a2451f4a13
commit
5561825584
8 changed files with 88 additions and 47 deletions
|
@ -1,27 +1,5 @@
|
|||
module Admin
|
||||
class SessionsController < Devise::SessionsController
|
||||
def new
|
||||
@admin_user = AdminUser.new
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:admin_user].blank?
|
||||
@admin_user = AdminUser.new
|
||||
flash[:alert] = 'Something went wrong'
|
||||
return render :new
|
||||
end
|
||||
|
||||
@admin_user = AdminUser.find_by(username: params[:admin_user][:username])
|
||||
@admin_user ||= AdminUser.new(username: params[:admin_user][:username])
|
||||
|
||||
if @admin_user.valid_password?(params[:admin_user][:password])
|
||||
sign_in_and_redirect(:admin_user, @admin_user, event: :authentication)
|
||||
else
|
||||
flash[:alert] = 'Authorization error'
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def after_sign_in_path_for(_resource_or_scope)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue