lib/authenticate/model/username.rb in authenticate-0.3.1 vs lib/authenticate/model/username.rb in authenticate-0.3.2
- old
+ new
@@ -1,19 +1,19 @@
module Authenticate
module Model
-
+ #
# Use :username as the identifier for the user. Username must be unique.
#
# = Columns
# * username - the username of your user
#
# = Validations
# * :username requires username is set, ensure it is unique
#
# = class methods
# * credentials(params) - return the credentials required for authorization by username
- # * authenticate(credentials) - find user with given username, validate their password, return the user if authenticated
+ # * authenticate(credentials) - find user with given username, validate their password, return user if authenticated
# * find_by_credentials(credentials) - find and return the user with the username in the credentials
#
module Username
extend ActiveSupport::Concern
@@ -26,10 +26,11 @@
validates :username,
presence: true,
uniqueness: { allow_blank: true }
end
+ # Class methods for managing username-based authentication
module ClassMethods
def credentials(params)
[params[:session][:username], params[:session][:password]]
end
@@ -40,12 +41,9 @@
def find_by_credentials(credentials)
username = credentials[0]
find_by_username username
end
-
end
-
end
-
end
end