Add complete user onboarding flow that redirects new users to complete their profile before accessing the application: - Add onboarding_completed boolean field to users with migration - Create OnboardingController with form validation and completion logic - Design professional onboarding UI with progressive disclosure for company info - Implement Stimulus controller for toggling company information section - Add application-wide redirect middleware for incomplete users - Create comprehensive test suite for all onboarding functionality - Update test fixtures and helpers to support onboarding in existing tests The onboarding collects required first/last name and optional company information. Users are redirected to onboarding after login until profile is completed. Features smooth animations, full-width form button, and clean UX design. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.6 KiB
Ruby
Executable File
46 lines
1.6 KiB
Ruby
Executable File
# Base controller for the application
|
|
# Provides common functionality and security configurations for all controllers
|
|
class ApplicationController < ActionController::Base
|
|
# Protect against Cross-Site Request Forgery (CSRF) attacks
|
|
# Ensures that all non-GET requests include a valid authenticity token
|
|
protect_from_forgery with: :exception
|
|
|
|
# Redirect authenticated users to onboarding if not completed
|
|
before_action :require_onboarding_completion
|
|
|
|
# Restrict access to modern browsers only
|
|
# Requires browsers to support modern web standards:
|
|
# - WebP images for better compression
|
|
# - Web Push notifications
|
|
# - Badge API for notifications
|
|
# - Import maps for JavaScript modules
|
|
# - CSS nesting and :has() pseudo-class
|
|
# allow_browser versions: :modern
|
|
# allow_browser versions: { safari: 16.4, firefox: 121, ie: false }
|
|
|
|
private
|
|
|
|
def require_onboarding_completion
|
|
# Skip onboarding check for these paths
|
|
return if skip_onboarding_check?
|
|
|
|
# Only apply to signed-in users
|
|
if user_signed_in? && current_user.needs_onboarding?
|
|
redirect_to onboarding_path unless request.path == onboarding_path
|
|
end
|
|
end
|
|
|
|
def skip_onboarding_check?
|
|
# Skip for devise controllers (login, signup, password reset, etc.)
|
|
devise_controller? ||
|
|
# Skip for onboarding controller itself
|
|
controller_name == "onboarding" ||
|
|
# Skip for API endpoints
|
|
controller_name.start_with?("api/") ||
|
|
# Skip for health checks
|
|
controller_name == "rails/health" ||
|
|
# Skip for home page (when not signed in)
|
|
(controller_name == "pages" && action_name == "home")
|
|
end
|
|
end
|