Class: Tramway::Auth::Web::SessionsController
Instance Method Summary
collapse
#authenticate_user!, #current_user, #sign_in, #sign_out, #signed_in?
#application
Instance Method Details
#create ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/tramway/auth/web/sessions_controller.rb', line 8
def create
@session_form = ::Tramway::Auth::SessionForm.new params[:model].constantize.active.find_by email: params[:user][:email]
if @session_form.model.present?
if @session_form.validate params[:user]
sign_in @session_form.model
redirect_to [params[:success_redirect], '?', { flash: :success_user_sign_in }.to_query].join || ::Tramway::Auth.root_path_for(@session_form.model.class)
else
redirect_to [params[:error_redirect], '?', { flash: :error_user_sign_in }.to_query].join || ::Tramway::Auth.root_path_for(@session_form.model.class)
end
else
redirect_to [params[:error_redirect], '?', { flash: :error_user_sign_in }.to_query].join || ::Tramway::Auth.root_path_for(params[:model].constantize)
end
end
|
#destroy ⇒ Object
22
23
24
25
26
|
# File 'app/controllers/tramway/auth/web/sessions_controller.rb', line 22
def destroy
root_path = ::Tramway::Auth.root_path_for(current_user.class)
sign_out params[:model]
redirect_to params[:redirect] || root_path
end
|