Class: Tramway::Auth::Web::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tramway/auth/web/sessions_controller.rb

Instance Method Summary collapse

Methods included from Tramway::AuthManagement

#authenticate_admin!, #authenticate_user!, #current_user, #sign_in, #sign_out, #signed_in?

Methods inherited from ApplicationController

#application

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/tramway/auth/web/sessions_controller.rb', line 13

def create
  @session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.active.find_or_initialize_by email: params[:user][:email]
  if @session_form.validate params[:user]
     @session_form.model
    redirect_to ::Tramway::Auth.root_path
  else
    render :new
  end
end

#destroyObject



23
24
25
26
# File 'app/controllers/tramway/auth/web/sessions_controller.rb', line 23

def destroy
  sign_out
  redirect_to ::Tramway::Auth.root_path
end

#newObject



8
9
10
11
# File 'app/controllers/tramway/auth/web/sessions_controller.rb', line 8

def new
  @application = Tramway::Core.application&.model_class&.first || Tramway::Core.application
  @session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.new
end