feat(auth): implement authentication system foundation

Add user authentication infrastructure with login/logout functionality,
session management, and basic user model.

Changes:
- Create users table with email, password_digest, confirmation tokens
- Add Users repository with authentication methods
- Add User entity with authentication helpers
- Implement login form and authentication actions
- Add logout action
- Add BCrypt gem for password hashing
- Update base Action class with authentication helpers
- Add login/logout routes

Next steps: Registration flow, password reset, email confirmation
This commit is contained in:
2026-03-27 12:25:08 -07:00
parent f88c1f5a7f
commit e7ddd0f72f
8 changed files with 339 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
# frozen_string_literal: true
module EuchreCamp
module Entities
class User < Dry::Struct
attribute :id, Types::Integer
attribute :player_id, Types::Integer
attribute :email, Types::String
attribute :password_digest, Types::String
attribute :confirmed, Types::Bool
attribute? :confirmation_token, Types::String.optional
attribute? :confirmation_sent_at, Types::Time.optional
attribute? :reset_password_token, Types::String.optional
attribute? :reset_password_sent_at, Types::Time.optional
attribute :failed_login_attempts, Types::Integer
attribute? :locked_until, Types::Time.optional
attribute? :last_login_at, Types::Time.optional
attribute? :last_login_ip, Types::String.optional
attribute :created_at, Types::Time
attribute :updated_at, Types::Time
# Check if account is locked
def locked?
locked_until && locked_until > Time.now
end
# Check if account is confirmed
def active?
confirmed && !locked?
end
# Check if user is admin (for navigation purposes)
# This would be enhanced with actual role checking later
def admin?
false # Placeholder - implement role checking later
end
end
end
end