Class: User

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Authpwn::UserModel
Defined in:
lib/authpwn_rails/generators/templates/user.rb

Overview

An user account.

Class Method Summary collapse

Methods included from Authpwn::UserModel

#auth_bounce_reason, #set_default_exuid, #to_param

Class Method Details

.authenticate_signin(signin) ⇒ User, Symbol

Change this to customize user lookup in the e-mail/password signin process.

For example, to implement Facebook / Twitter’s ability to log in using either an e-mail address or a username, look up the user by the username, create a new Session with the e-mail and password, and pass it to super

Parameters:

  • signin (Session)

    the information entered in the sign-in form

Returns:

  • (User, Symbol)

    the authenticated user, or a symbol indicating the reason why the authentication failed



21
22
23
# File 'lib/authpwn_rails/generators/templates/user.rb', line 21

def self.()
  super
end

.create_from_omniauth(omniauth_hash) ⇒ User

Change this to customize on-demand user creation on OmniAuth signup.

This method is called when there is no existing user matching the OmniAuth information, and is responsible for creating a user. It is an opportunity to collect the OmniAuth information to populate the user’s account.

The default implementation creates a user with the e-mail matching the ‘email’ key in the OmniAuth hash. If no e-mail key is present, no User is created.

Parameters:

  • omniauth_hash (Hash)

    the hash provided by OmniAuth

Returns:

  • (User)

    a saved User, or nil if the OmniAuth sign-in information should not be used to create a user



54
55
56
# File 'lib/authpwn_rails/generators/templates/user.rb', line 54

def self.create_from_omniauth(omniauth_hash)
  super
end

Change this to customize user lookup in the OmniAuth signup process.

This method is called when there is no Credential matching the OmniAuth information, but before create_from_omniauth. It is an opportunity to identify an existing user who uses a new sign-in method.

The default implementation finds an user whose e-mail matches the ‘email’ value in the OmniAuth hash.

Parameters:

  • omniauth_hash (Hash)

    the hash provided by OmniAuth

Returns:

  • (User)

    the user who should be signed in, or nil if no such user exists



37
38
39
# File 'lib/authpwn_rails/generators/templates/user.rb', line 37

def self.related_to_omniauth(omniauth_hash)
  super
end