Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: authentic
version: 1.0.1
version: 1.0.2

authors:
- Paul Smith <paulcsmith0218@gmail.com>
Expand All @@ -11,12 +11,10 @@ license: MIT
dependencies:
lucky:
github: luckyframework/lucky
branch: main
# version: ">= 1.0.0"
version: ">= 1.0.0"
avram:
github: luckyframework/avram
branch: main
# version: ">= 1.0.0"
version: ">= 1.0.0"
habitat:
github: luckyframework/habitat
version: ~> 0.4.9
Expand Down
2 changes: 1 addition & 1 deletion spec/support/context_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ContextHelper

def initialize(
@path : String = "/",
@method : String = "GET"
@method : String = "GET",
)
end

Expand Down
12 changes: 6 additions & 6 deletions src/authentic.cr
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module Authentic
# page before sign in.
def self.redirect_to_originally_requested_path(
action : Lucky::Action,
fallback : Lucky::Action.class | Lucky::RouteHelper
fallback : Lucky::Action.class | Lucky::RouteHelper,
) : Lucky::Response
return_to = action.session.get?(:return_to)
action.session.delete(:return_to)
Expand All @@ -92,7 +92,7 @@ module Authentic
# ```
def self.correct_password?(
authenticatable : Authentic::PasswordAuthenticatable,
password_value : String
password_value : String,
) : Bool
encrypted_password = authenticatable.encrypted_password

Expand All @@ -119,7 +119,7 @@ module Authentic
# ```
def self.copy_and_encrypt(
from password_field : Avram::Attribute | Avram::PermittedAttribute,
to encrypted_password_field : Avram::Attribute | Avram::PermittedAttribute
to encrypted_password_field : Avram::Attribute | Avram::PermittedAttribute,
) : Nil
password_field.value.try do |value|
encrypted_password_field.value = generate_encrypted_password(value)
Expand All @@ -131,7 +131,7 @@ module Authentic
# By default it uses Bcrypt to encrypt the password.
def self.generate_encrypted_password(
password_value : String,
encryptor = Crypto::Bcrypt::Password
encryptor = Crypto::Bcrypt::Password,
) : String
encryptor.create(
password_value,
Expand All @@ -142,7 +142,7 @@ module Authentic
# Generates a password reset token
def self.generate_password_reset_token(
authenticatable : Authentic::PasswordAuthenticatable,
expires_in : Time::Span = Authentic.settings.default_password_reset_time_limit
expires_in : Time::Span = Authentic.settings.default_password_reset_time_limit,
) : String
encryptor = Lucky::MessageEncryptor.new(secret: settings.secret_key)
encryptor.encrypt_and_sign("#{authenticatable.id}:#{expires_in.from_now.to_unix_ms}")
Expand All @@ -156,7 +156,7 @@ module Authentic
# To generate a token see `Authentic.generate_password_reset_token`
def self.valid_password_reset_token?(
authenticatable : Authentic::PasswordAuthenticatable,
token : String
token : String,
) : Bool
encryptor = Lucky::MessageEncryptor.new(secret: settings.secret_key)
user_id, expiration_in_ms = String.new(encryptor.verify_and_decrypt(token)).split(":")
Expand Down
2 changes: 1 addition & 1 deletion src/authentic/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Authentic
VERSION = "1.0.1"
VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }}
end
Loading