class Authentication::Base

Defined in:

authentication.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(set_password_hash = "", set_password = "") #

Create an instance

NOTE You can set password hash with set_password_hash: "password_hash" or set password with set_password: "password"

Example:

authentication = Authentication::Base.new set_password_hash: "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"
authentication2 = Authentication::Base.new set_password: "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"

[View source]

Class Method Detail

def self.check_cost : Bool #

[View source]
def self.cost #

Get cost

Example:

Authentication::Base.cost = 15 # => Bool(true)
Authentication::Base.cost      # => 15

[View source]
def self.cost=(cost : Int32) #

Set cost

Example:

Authentication::Base.cost = 15 # => Bool(true)
Authentication::Base.cost = 3  # raise CostTooLow("Cost too low, 4 minimum is required (current cost 3)") exception

[View source]

Instance Method Detail

def authenticate(password : String, set_password_hash = "") : Bool #

Authenticate

NOTE You can set the password_hash here with set_password_hash: password_hash

Example:

authentication = Authentication::Base.new set_password: test
authentication.authenticate "test"

[View source]
def password=(password : String) : String #

Set password

Example:

authentication = Authentication::Base.new
authentication.password = "test" # => "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"

[View source]
def password_hash : String #

Get password_hash

Example:

authentication = Authentication::Base.new set_password_hash: "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"
authentication.password_hash # => "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"

[View source]
def password_hash=(set_password_hash : String) : String #

Set password_hash

Example:

authentication = Authentication::Base.new
authentication.password_hash = "$2a$16$YXplcnR5dWlvcHFzZGZna.zN8.evmDPoNK.n.l6cx0YKKnw37jd9K"

[View source]