Class: Symphonia::LoginController

Inherits:
ApplicationController show all
Defined in:
app/controllers/symphonia/login_controller.rb

Direct Known Subclasses

UserSessionsController

Instance Method Summary collapse

Methods included from ControllerExtensions

#admin_require, #authorize, #back_url, #current_user, #current_user_session, #handle_unverified_request, #login_require, #menu_item, #redirect_back_or_default, #redirect_to_referer_or, #render_403, #render_404, #render_api_head, #render_api_ok, #set_default_locale, #set_locale, #store_location

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/symphonia/login_controller.rb', line 22

def create
  @model_session = "#{current_model}Session".constantize.new()
  if @model_session.save
    current_model.constantize.current = @model_session.user
    redirect_to 
  else
    render :new
  end
end

#destroyObject



36
37
38
39
40
# File 'app/controllers/symphonia/login_controller.rb', line 36

def destroy
  current_session && current_session.destroy
  session.delete :return_to
  redirect_to '/', notice: t(:text_successfully_logout)
end

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/symphonia/login_controller.rb', line 6

def index
  if current_model.constantize.current.logged_in?
    return destroy
  else
    return new
  end
end

#login_session_paramsObject



32
33
34
# File 'app/controllers/symphonia/login_controller.rb', line 32

def 
  params.require(:login_session).permit(:login, :password, :remember_me).to_h
end

#newObject



14
15
16
17
18
19
20
# File 'app/controllers/symphonia/login_controller.rb', line 14

def new
  if current_model.constantize.current.logged_in?
    return redirect_to()
  end
  @model_session = "#{current_model}Session".constantize.new
  render :new
end