Class: Searls::Auth::HelperMethods

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/searls/auth/application_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ HelperMethods

Returns a new instance of HelperMethods.



4
5
6
# File 'app/helpers/searls/auth/application_helper.rb', line 4

def initialize(view_context)
  @view_context = view_context
end

Instance Method Details

#attr_for(model, field_name) ⇒ Object



61
62
63
64
65
# File 'app/helpers/searls/auth/application_helper.rb', line 61

def attr_for(model, field_name)
  if model.respond_to?(field_name)
    model.send(field_name)
  end
end

#email_field_stimulus_dataObject



40
41
42
43
44
# File 'app/helpers/searls/auth/application_helper.rb', line 40

def email_field_stimulus_data
  {
    action: "change->searls-auth-login#updateEmail"
  }
end

#enable_turbo?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/helpers/searls/auth/application_helper.rb', line 57

def enable_turbo?
  params[:redirect_subdomain].blank? || params[:redirect_subdomain] == request.subdomain
end

#login_path(**kwargs) ⇒ Object



12
13
14
# File 'app/helpers/searls/auth/application_helper.rb', line 12

def (**kwargs)
  routes.(forwardable_params.merge(kwargs))
end

#login_stimulus_controllerObject



36
37
38
# File 'app/helpers/searls/auth/application_helper.rb', line 36

def 
  "searls-auth-login"
end

#login_url(**kwargs) ⇒ Object



16
17
18
# File 'app/helpers/searls/auth/application_helper.rb', line 16

def (**kwargs)
  routes.(forwardable_params.merge(kwargs))
end

#otp_field_stimulus_dataObject



50
51
52
53
54
55
# File 'app/helpers/searls/auth/application_helper.rb', line 50

def otp_field_stimulus_data
  {
    action: "paste->searls-auth-otp#pasted input->otp#caret click->searls-auth-otp#caret keydown->searls-auth-otp#caret keyup->searls-auth-otp#caret",
    searls_auth_otp_target: "input"
  }
end

#otp_stimulus_controllerObject



46
47
48
# File 'app/helpers/searls/auth/application_helper.rb', line 46

def otp_stimulus_controller
  "searls-auth-otp"
end

#password_reset_available?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/helpers/searls/auth/application_helper.rb', line 32

def password_reset_available?
  Searls::Auth.config.password_reset_enabled?
end

#password_reset_request_path(**kwargs) ⇒ Object



28
29
30
# File 'app/helpers/searls/auth/application_helper.rb', line 28

def password_reset_request_path(**kwargs)
  routes.password_reset_request_path(forwardable_params.merge(kwargs))
end

#register_path(**kwargs) ⇒ Object



20
21
22
# File 'app/helpers/searls/auth/application_helper.rb', line 20

def register_path(**kwargs)
  routes.register_path(forwardable_params.merge(kwargs))
end

#register_url(**kwargs) ⇒ Object



24
25
26
# File 'app/helpers/searls/auth/application_helper.rb', line 24

def register_url(**kwargs)
  routes.register_url(forwardable_params.merge(kwargs))
end

#routesObject



8
9
10
# File 'app/helpers/searls/auth/application_helper.rb', line 8

def routes
  Searls::Auth::Engine.routes.url_helpers
end

#rpad(s, spacer = " ", times = 1) ⇒ Object



67
68
69
70
# File 'app/helpers/searls/auth/application_helper.rb', line 67

def rpad(s, spacer = " ", times = 1)
  return "" if s.blank?
  "#{s}#{spacer * times}"
end