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
#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
#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_location ⇒ Object
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 account_for email
Auth.find_account_by_email 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 authenticate_and_signin email, pword
return unless (account = Auth.authenticate email, pword)
Auth.signin account.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
authenticate_and_signin(email, pword) || failed_signin(email)
end
|
#blank_email? ⇒ 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_field ⇒ Object
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_token ⇒ Object
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: signin ⇒ Object
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_success ⇒ Object
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: signout ⇒ Object
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.signin 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 failed_signin email
errors.add :signin, signin_error_message(account_for(email))
abort :failure
end
|
#ok_to_read? ⇒ 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
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 account
if account
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 account
Auth.as_bot { account.send_password_reset_email }
end
|
#send_reset_password_email_or_fail ⇒ Object
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 (account = account_for email_from_field)&.active?
send_reset_password_email account
else
reset_password_fail account
end
end
|
#signin_error_message(account) ⇒ Object
73
74
75
|
# File 'platypus/tmp/set/gem-defaults/mod014-account/self/signin.rb', line 73
def signin_error_message account
t "account_#{signin_error_key account}"
end
|