class OmniAuth::Strategies::Standalone
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/standalone.rb, line 40 def callback_phase try_to_register super end
request_phase()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 36 def request_phase sign_up? ? build_sign_up_form : build_sign_in_form end
Private Instance Methods
build_sign_in_form()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 55 def build_sign_in_form SignInForm.new(sign_in_fields, nil, callback_path).render end
build_sign_up_form()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 51 def build_sign_up_form SignUpForm.new(sign_up_fields, sign_up_checkboxes, callback_path).render end
confirm(key)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 168 def confirm(key) "authentication.errors.#{key}.unconfirmed" end
email?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 136 def email? exist?('email') end
ensure_email_exists()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 108 def ensure_email_exists unless email? fail_with AuthenticationError.new(missing('email')) end end
ensure_name_exists()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 102 def ensure_name_exists unless name? fail_with AuthenticationError.new(missing('name')) end end
ensure_password_confirmation_exists()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 120 def ensure_password_confirmation_exists unless password_confirmation? fail_with AuthenticationError.new(missing('password_confirmation')) end end
ensure_password_confirmed()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 126 def ensure_password_confirmed unless password_confirmed? fail_with AuthenticationError.new(confirm('password')) end end
ensure_password_exists()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 114 def ensure_password_exists unless password? fail_with AuthenticationError.new(missing('password')) end end
error()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 172 def error env['omniauth.error'] end
error?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 176 def error? !!error end
exist?(attr)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 152 def exist?(attr) !!request.params[attr] && !request.params[attr].blank? end
fail_with(exception)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 160 def fail_with(exception) env['omniauth.error'] = exception end
generate_uid(*args)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 47 def generate_uid(*args) Digest::SHA256.hexdigest(args.join(''))[0..19] end
missing(key)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 164 def missing(key) "authentication.errors.#{key}.missing" end
name?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 132 def name? exist?('name') end
password?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 140 def password? exist?('password') end
password_confirmation?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 144 def password_confirmation? exist?('password_confirmation') end
password_confirmed?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 148 def password_confirmed? same?('password', 'password_confirmation') end
same?(first, second)
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 156 def same?(first, second) request.params[first] == request.params[second] end
sign_in?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 97 def sign_in? @env['QUERY_STRING'].match(/sign_in/) || !sign_up? end
sign_in_fields()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 67 def sign_in_fields ['email', 'password'] end
sign_up?()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 92 def sign_up? @env['QUERY_STRING'].match(/sign_up/) || !!request.params['password_confirmation'] end
sign_up_checkboxes()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 63 def sign_up_checkboxes ['terms_accepted', 'opt_in'] end
sign_up_fields()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 59 def sign_up_fields options.fields << 'password' << 'password_confirmation' end
try_to_register()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 71 def try_to_register if sign_up? ensure_password_confirmed ensure_password_confirmation_exists ensure_password_exists ensure_email_exists ensure_name_exists end if sign_in? ensure_password_exists ensure_email_exists end validate! end
validate!()
click to toggle source
# File lib/omniauth/strategies/standalone.rb, line 88 def validate! fail!(error) if error? end