Module: Card::Set::Self::Signin

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb

Overview

The Sign In card manages logging in and out of the site.

Defined Under Namespace

Modules: HtmlFormat

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



9
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 9

def self.source_location; "/Users/ethan/dev/decko/gem/mod/account/set/self/signin.rb"; end

Instance Method Details

#abort_unless(value, error_key) ⇒ Object



69
70
71
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 69

def abort_unless value, error_key
  abort :failure, t("account_#{error_key}") unless value
end

#account_for(email) ⇒ Object



81
82
83
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 81

def  email
  Auth. email
end

#authenticate_and_signin(email, pword) ⇒ Object



58
59
60
61
62
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 58

def  email, pword
  return unless ( = Auth.authenticate email, pword)

  Auth. .left_id
end

#authenticate_or_abort(email, pword) ⇒ Object



52
53
54
55
56
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 52

def authenticate_or_abort email, pword
  abort_unless email, :email_missing
  abort_unless pword, :password_missing
  (email, pword) || (email)
end

#blank_email?Boolean

Returns:

  • (Boolean)


93
94
95
96
97
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 93

def blank_email?
  return false if email_from_field.present?

  error_on :email, :error_blank
end

#email_from_fieldObject



40
41
42
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 40

def email_from_field
  @email_from_field ||= field_content(:email)
end

#error_on(field, error_key) ⇒ Object



77
78
79
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 77

def error_on field, error_key
  errors.add field, t("account_#{error_key}")
end

#event: send_reset_password_tokenObject

triggered by clicking “Reset Password”, this sends out the verification password and aborts (does not sign in)



34
35
36
37
38
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 34

event :send_reset_password_token, before: :signin, on: :update, trigger: :required do
  aborting do
    blank_email? ? break : send_reset_password_email_or_fail
  end
end

#event: signinObject

authentication event



17
18
19
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 17

event :signin, :validate, on: :update do
  authenticate_or_abort field_content(:email), field_content(:password)
end

#event: signin_successObject

abort after successful signin (do not save card)



22
23
24
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 22

event :signin_success, after: :signin do
  abort :success
end

#event: signoutObject



26
27
28
29
30
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 26

event :signout, :validate, on: :delete do
  Env.reset_session
  Auth. AnonymousID
  abort :success
end

#failed_signin(email) ⇒ Object



64
65
66
67
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 64

def  email
  errors.add :signin, ((email))
  abort :failure
end

#ok_to_read?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 44

def ok_to_read?
  true
end

#recaptcha_on?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 48

def recaptcha_on?
  false
end

#reset_password_fail(account) ⇒ Object



103
104
105
106
107
108
109
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 103

def reset_password_fail 
  if 
    error_on :account, :error_not_active
  else
    error_on :email, :error_not_recognized
  end
end

#send_reset_password_email(account) ⇒ Object



99
100
101
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 99

def send_reset_password_email 
  Auth.as_bot { .send_password_reset_email }
end

#send_reset_password_email_or_failObject



85
86
87
88
89
90
91
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 85

def send_reset_password_email_or_fail
  if ( =  email_from_field)&.active?
    send_reset_password_email 
  else
    reset_password_fail 
  end
end

#signin_error_message(account) ⇒ Object



73
74
75
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 73

def  
  t "account_#{ }"
end