Class: Searls::Auth::LoginsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/searls/auth/logins_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/searls/auth/logins_controller.rb', line 10

def create
  user = searls_auth_config.user_finder_by_email.call(params[:email])

  if user.present?
    attach_short_code_to_session!(user)
    EmailsLink.new.email(
      user:,
      redirect_path: params[:redirect_path],
      redirect_subdomain: params[:redirect_subdomain],
      short_code: session[:searls_auth_short_code]
    )
    flash[:notice] = searls_auth_config.resolve(
      :flash_notice_after_login_attempt,
      user, params
    )
    redirect_to searls_auth.verify_path(
      redirect_path: params[:redirect_path],
      redirect_subdomain: params[:redirect_subdomain]
    )
  else
    flash.now[:error] = searls_auth_config.resolve(
      :flash_error_after_login_attempt_unknown_email,
      searls_auth.register_path(
        email: params[:email],
        redirect_path: params[:redirect_path],
        redirect_subdomain: params[:redirect_subdomain]
      ),
      params
    )
    render searls_auth_config., layout: searls_auth_config.layout, status: :unprocessable_entity
  end
end

#destroyObject


43
44
45
46
47
48
49
50
51
# File 'app/controllers/searls/auth/logins_controller.rb', line 43

def destroy
  ResetsSession.new.reset(self, except_for: [:has_logged_in_before])

  flash[:notice] = searls_auth_config.resolve(
    :flash_notice_after_logout,
    params
  )
  redirect_to searls_auth.
end

#showObject


6
7
8
# File 'app/controllers/searls/auth/logins_controller.rb', line 6

def show
  render searls_auth_config., layout: searls_auth_config.layout
end