module SignIn

Please see README

Public Instance Methods

sign_in(options=nil) click to toggle source

The sign_in method calls:

# File lib/sixarm_ruby_sign_in.rb, line 14
def sign_in(options=nil)
  begin
   sign_in_attempt(options) or raise SecurityError
   sign_in_success(options)
   return true
  rescue SecurityError
   sign_in_failure(options)
   return false
  end
end
sign_in_attempt(options=nil) click to toggle source

The sign_in method calls this first.

You override this method to e.g.:

  • get a username and password from params

  • find the user by username in the user model

  • authenticate the user by verifying the password

If this method succeeds, then control goes to sign_in_success.

If this method raises an error, then control goes to sign_in_failure.

# File lib/sixarm_ruby_sign_in.rb, line 37
def sign_in_attempt(options=nil)
end
sign_in_failure(options=nil) click to toggle source

The sign_in method calls this second, iff sign_in_attempt raises an exception.

You override this method to e.g.:

  • show the user a flash warning message saying “Sorry…”

  • redirect to a help page

  • log the attempt and possibly see if it’s a hacker

# File lib/sixarm_ruby_sign_in.rb, line 61
def sign_in_failure(options=nil)
end
sign_in_success(options=nil) click to toggle source

The sign_in method calls this second, iff sign_in_attempt succeeds.

You override this method to e.g.:

  • show the user a flash notice message saying “Welcome…”

  • redirect to the user’s home page

  • customize views based on the user’s info

# File lib/sixarm_ruby_sign_in.rb, line 49
def sign_in_success(options=nil)
end