From e83b789c589e67b682703a9ce2a5defd4fa6656b Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 21 Apr 2025 18:11:53 -0700 Subject: [PATCH 01/16] Begin adding passwordless --- Gemfile | 2 ++ Gemfile.lock | 5 ++++ app/controllers/application_controller.rb | 15 +++++++++++ app/controllers/progress_page_controller.rb | 1 + .../sessions/login_page_controller.rb | 5 ++++ app/controllers/settings_page_controller.rb | 1 + app/controllers/tasks/today_controller.rb | 2 ++ app/frontend/pages/LoginPage.vue | 5 ++++ app/models/user.rb | 6 +++++ config/routes.rb | 4 +++ ...sswordless_sessions.passwordless_engine.rb | 23 +++++++++++++++++ db/migrate/20250422002120_change_users.rb | 6 +++++ db/schema.rb | 25 +++++++++++++------ 13 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 app/controllers/sessions/login_page_controller.rb create mode 100644 app/frontend/pages/LoginPage.vue create mode 100644 db/migrate/20250422001809_create_passwordless_sessions.passwordless_engine.rb create mode 100644 db/migrate/20250422002120_change_users.rb diff --git a/Gemfile b/Gemfile index cb00ed3..a9bb41a 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,8 @@ gem 'bootsnap', require: false # Draper adds an object-oriented layer of presentation logic to your Rails application. gem 'draper' +gem 'passwordless' + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem 'debug', platforms: %i[mri mswin mswin64 mingw x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 04482a0..60687b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,6 +84,7 @@ GEM ast (2.4.2) backport (1.2.0) base64 (0.2.0) + bcrypt (3.1.20) benchmark (0.4.0) bigdecimal (3.1.8) bindex (0.8.1) @@ -187,6 +188,9 @@ GEM parser (3.3.7.1) ast (~> 2.4.1) racc + passwordless (1.8.1) + bcrypt (>= 3.1.11) + rails (>= 5.1.4) pg (1.5.6) pry (0.14.2) coderay (~> 1.1) @@ -355,6 +359,7 @@ DEPENDENCIES error_highlight (>= 0.4.0) inertia_rails-contrib (~> 0.1.1) jbuilder + passwordless pg (~> 1.1) pry-byebug puma (>= 5.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a8cd925..0d7cac0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,9 @@ class ApplicationController < ActionController::Base + include Passwordless::ControllerHelpers # <-- This! before_action :initialize_progs + helper_method :current_user + private def initialize_progs @@ -10,4 +13,16 @@ def initialize_progs ProgService.initialize_progs session[:initialize_progs] = today end + + def current_user + @current_user ||= authenticate_by_session(User) + end + + def require_user! + return if Rails.env.development? + return if current_user + + save_passwordless_redirect_location!(User) # <-- optional, see below + redirect_to login_path, inertia: { props: { random_prop: 'prop' } } + end end diff --git a/app/controllers/progress_page_controller.rb b/app/controllers/progress_page_controller.rb index 7363e3c..9393090 100644 --- a/app/controllers/progress_page_controller.rb +++ b/app/controllers/progress_page_controller.rb @@ -1,4 +1,5 @@ class ProgressPageController < ApplicationController + before_action :require_user! def index render inertia: 'ProgressPage', props: { progs: Goal.last.daily_progs, startdate: Goal.last.start_date } end diff --git a/app/controllers/sessions/login_page_controller.rb b/app/controllers/sessions/login_page_controller.rb new file mode 100644 index 0000000..30d0964 --- /dev/null +++ b/app/controllers/sessions/login_page_controller.rb @@ -0,0 +1,5 @@ +class Sessions::LoginPageController < ApplicationController + def index + render inertia: 'LoginPage', props: { prop: 'random' } + end +end diff --git a/app/controllers/settings_page_controller.rb b/app/controllers/settings_page_controller.rb index d4cba92..d4b8003 100644 --- a/app/controllers/settings_page_controller.rb +++ b/app/controllers/settings_page_controller.rb @@ -1,4 +1,5 @@ class SettingsPageController < ApplicationController + before_action :require_user! def index tasks = TaskService.fetch_today_tasks render inertia: 'SettingsPage', props: { tasks: tasks } diff --git a/app/controllers/tasks/today_controller.rb b/app/controllers/tasks/today_controller.rb index 90b5cf1..945d16c 100644 --- a/app/controllers/tasks/today_controller.rb +++ b/app/controllers/tasks/today_controller.rb @@ -1,5 +1,7 @@ module Tasks class TodayController < ApplicationController + before_action :require_user! + def index render inertia: 'TodayPage', props: { tasks: collection } rescue StandardError => e diff --git a/app/frontend/pages/LoginPage.vue b/app/frontend/pages/LoginPage.vue new file mode 100644 index 0000000..e128115 --- /dev/null +++ b/app/frontend/pages/LoginPage.vue @@ -0,0 +1,5 @@ + diff --git a/app/models/user.rb b/app/models/user.rb index 379658a..9f1c75b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,2 +1,8 @@ class User < ApplicationRecord + validates :email, + presence: true, + uniqueness: { case_sensitive: false }, + format: { with: URI::MailTo::EMAIL_REGEXP } # <-- validates that the email is in correct format, and that it is unique + + passwordless_with :email # <-- tells Passwordless which field stores the email address end diff --git a/config/routes.rb b/config/routes.rb index ca3cfd9..4a0a44b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + passwordless_for :users # Defines the root path route ("/") root 'settings_page#index' @@ -12,6 +13,9 @@ get 'inertia-example', to: 'inertia_example#index' post 'inertia-example', to: 'inertia_example#increase_counter' + + get 'login', to: 'sessions/login_page#index' + post 'login', to: 'sessions/login_page#create' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. diff --git a/db/migrate/20250422001809_create_passwordless_sessions.passwordless_engine.rb b/db/migrate/20250422001809_create_passwordless_sessions.passwordless_engine.rb new file mode 100644 index 0000000..f026007 --- /dev/null +++ b/db/migrate/20250422001809_create_passwordless_sessions.passwordless_engine.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# This migration comes from passwordless_engine (originally 20171104221735) +class CreatePasswordlessSessions < ActiveRecord::Migration[6.0] + def change + create_table(:passwordless_sessions) do |t| + t.belongs_to( + :authenticatable, + polymorphic: true, + type: :int, # change to e.g. :uuid if your model doesn't use integer IDs + index: { name: "authenticatable" } + ) + + t.datetime(:timeout_at, null: false) + t.datetime(:expires_at, null: false) + t.datetime(:claimed_at) + t.string(:token_digest, null: false) + t.string(:identifier, null: false, index: { unique: true }, length: 36) + + t.timestamps + end + end +end diff --git a/db/migrate/20250422002120_change_users.rb b/db/migrate/20250422002120_change_users.rb new file mode 100644 index 0000000..657342d --- /dev/null +++ b/db/migrate/20250422002120_change_users.rb @@ -0,0 +1,6 @@ +class ChangeUsers < ActiveRecord::Migration[7.1] + def change + add_index :users, 'LOWER(email)', unique: true, name: 'index_users_on_lowercase_email' # <-- prevent duplicate emails + change_column_null :users, :email, false + end +end diff --git a/db/schema.rb b/db/schema.rb index 33f3203..40f3cf3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,16 +10,10 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_02_17_005822) do +ActiveRecord::Schema[7.1].define(version: 2025_04_22_002120) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" - create_table "counters", force: :cascade do |t| - t.integer "click" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "daily_progs", force: :cascade do |t| t.bigint "goal_id", null: false t.date "date" @@ -38,6 +32,20 @@ t.datetime "updated_at", null: false end + create_table "passwordless_sessions", force: :cascade do |t| + t.string "authenticatable_type" + t.integer "authenticatable_id" + t.datetime "timeout_at", precision: nil, null: false + t.datetime "expires_at", precision: nil, null: false + t.datetime "claimed_at", precision: nil + t.string "token_digest", null: false + t.string "identifier", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["authenticatable_type", "authenticatable_id"], name: "authenticatable" + t.index ["identifier"], name: "index_passwordless_sessions_on_identifier", unique: true + end + create_table "task_progs", force: :cascade do |t| t.bigint "daily_prog_id", null: false t.bigint "task_id", null: false @@ -63,10 +71,11 @@ create_table "users", force: :cascade do |t| t.date "timezone" t.string "username" - t.string "email" + t.string "email", null: false t.boolean "show_progress", default: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index "lower((email)::text)", name: "index_users_on_lowercase_email", unique: true end add_foreign_key "daily_progs", "goals" From 58754b8e53dc2e829300b037eacfd1acca77cc60 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 28 Apr 2025 18:13:15 -0700 Subject: [PATCH 02/16] change to use authenticated_controller --- app/controllers/authenticated_controller.rb | 3 +++ app/controllers/progress_page_controller.rb | 3 +-- app/controllers/settings_page_controller.rb | 3 +-- app/controllers/tasks/today_controller.rb | 4 +--- 4 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 app/controllers/authenticated_controller.rb diff --git a/app/controllers/authenticated_controller.rb b/app/controllers/authenticated_controller.rb new file mode 100644 index 0000000..7eb5c40 --- /dev/null +++ b/app/controllers/authenticated_controller.rb @@ -0,0 +1,3 @@ +class AuthenticatedController < ApplicationController + before_action :require_user! +end diff --git a/app/controllers/progress_page_controller.rb b/app/controllers/progress_page_controller.rb index 9393090..900127c 100644 --- a/app/controllers/progress_page_controller.rb +++ b/app/controllers/progress_page_controller.rb @@ -1,5 +1,4 @@ -class ProgressPageController < ApplicationController - before_action :require_user! +class ProgressPageController < AuthenticatedController def index render inertia: 'ProgressPage', props: { progs: Goal.last.daily_progs, startdate: Goal.last.start_date } end diff --git a/app/controllers/settings_page_controller.rb b/app/controllers/settings_page_controller.rb index d4b8003..af53185 100644 --- a/app/controllers/settings_page_controller.rb +++ b/app/controllers/settings_page_controller.rb @@ -1,5 +1,4 @@ -class SettingsPageController < ApplicationController - before_action :require_user! +class SettingsPageController < AuthenticatedController def index tasks = TaskService.fetch_today_tasks render inertia: 'SettingsPage', props: { tasks: tasks } diff --git a/app/controllers/tasks/today_controller.rb b/app/controllers/tasks/today_controller.rb index 945d16c..1eee579 100644 --- a/app/controllers/tasks/today_controller.rb +++ b/app/controllers/tasks/today_controller.rb @@ -1,7 +1,5 @@ module Tasks - class TodayController < ApplicationController - before_action :require_user! - + class TodayController < AuthenticatedController def index render inertia: 'TodayPage', props: { tasks: collection } rescue StandardError => e From 2cb92e92f6facb8406fc97ddcbbb47043f39efc7 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 09:29:13 -0700 Subject: [PATCH 03/16] wip --- app/controllers/sessions_controller.rb | 11 ++++++++++ app/controllers/users_controller.rb | 12 +++++++++++ .../passwordless/mailer/sign_in.text.erb | 1 + app/views/passwordless/sessions/new.html.erb | 12 +++++++++++ app/views/passwordless/sessions/show.html.erb | 8 +++++++ app/views/sessions/new.html.erb | 21 +++++++++++++++++++ config/routes.rb | 2 +- 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/controllers/users_controller.rb create mode 100644 app/views/passwordless/mailer/sign_in.text.erb create mode 100644 app/views/passwordless/sessions/new.html.erb create mode 100644 app/views/passwordless/sessions/show.html.erb create mode 100644 app/views/sessions/new.html.erb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..2268403 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,11 @@ +class SessionsController < Passwordless::SessionsController + before_action :require_unauth!, only: %i[new show] + + private + + def require_unauth! + return unless current_user + + redirect_to('/', notice: 'You are already signed in.') + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..72fa659 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,12 @@ +class UsersController < ApplicationController + def create + @user = User.new(user_params) + + if @user.save + sign_in(create_passwordless_session(@user)) # <-- This! + redirect_to(@user, flash: { notice: 'Welcome!' }) + else + render(:new) + end + end +end diff --git a/app/views/passwordless/mailer/sign_in.text.erb b/app/views/passwordless/mailer/sign_in.text.erb new file mode 100644 index 0000000..e5d7850 --- /dev/null +++ b/app/views/passwordless/mailer/sign_in.text.erb @@ -0,0 +1 @@ +<%= t("passwordless.mailer.sign_in.body", token: @token, magic_link: @magic_link) %> diff --git a/app/views/passwordless/sessions/new.html.erb b/app/views/passwordless/sessions/new.html.erb new file mode 100644 index 0000000..831e45c --- /dev/null +++ b/app/views/passwordless/sessions/new.html.erb @@ -0,0 +1,12 @@ +<%= form_with(model: @session, url: url_for(action: 'new'), data: { turbo: 'false' }) do |f| %> + <% email_field_name = :"passwordless[#{email_field}]" %> + <%= f.label email_field_name, + t("passwordless.sessions.new.email.label"), + for: "passwordless_#{email_field}" %> + <%= email_field_tag email_field_name, + params.fetch(email_field_name, nil), + required: true, + autofocus: true, + placeholder: t("passwordless.sessions.new.email.placeholder") %> + <%= f.submit t("passwordless.sessions.new.submit") %> +<% end %> diff --git a/app/views/passwordless/sessions/show.html.erb b/app/views/passwordless/sessions/show.html.erb new file mode 100644 index 0000000..5ebb0e7 --- /dev/null +++ b/app/views/passwordless/sessions/show.html.erb @@ -0,0 +1,8 @@ +<%= form_with(model: @session, url: url_for(action: 'update'), scope: 'passwordless', method: 'patch', data: { turbo: false }) do |f| %> + <%= f.label :token, t(".token") %> + <%= f.text_field :token, + required: true, + autofocus: true, + autocomplete: "one-time-code" %> + <%= f.submit t(".confirm") %> +<% end %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..84f9afe --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,21 @@ +
+
+
+

+ Sign in to your account +

+
+ <%= form_with(model: @session, url: login_path, class: "mt-8 space-y-6") do |f| %> +
+
+ <%= f.label :email, class: "sr-only" %> + <%= f.email_field :email, required: true, class: "appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", placeholder: "Email address" %> +
+
+ +
+ <%= f.submit "Send magic link", class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %> +
+ <% end %> +
+
diff --git a/config/routes.rb b/config/routes.rb index 4a0a44b..b2a864b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - passwordless_for :users + passwordless_for :users, controller: 'sessions' # Defines the root path route ("/") root 'settings_page#index' From 6e73c75aaf1ba88726ff2d43b8b0c4c5fa3ad64b Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 09:57:10 -0700 Subject: [PATCH 04/16] add user ref to goals --- db/migrate/20250511163006_move_goals_to_users.rb | 11 +++++++++++ db/schema.rb | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250511163006_move_goals_to_users.rb diff --git a/db/migrate/20250511163006_move_goals_to_users.rb b/db/migrate/20250511163006_move_goals_to_users.rb new file mode 100644 index 0000000..b263c6b --- /dev/null +++ b/db/migrate/20250511163006_move_goals_to_users.rb @@ -0,0 +1,11 @@ +class MoveGoalsToUsers < ActiveRecord::Migration[7.1] + def up + Goal.destroy_all + + add_reference :goals, :user, null: false, foreign_key: true + end + + def down + remove_reference :goals, :user + end +end diff --git a/db/schema.rb b/db/schema.rb index 40f3cf3..f113e47 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2025_04_22_002120) do +ActiveRecord::Schema[7.1].define(version: 2025_05_11_163006) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -30,6 +30,8 @@ t.date "end_date" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "user_id", null: false + t.index ["user_id"], name: "index_goals_on_user_id" end create_table "passwordless_sessions", force: :cascade do |t| @@ -79,6 +81,7 @@ end add_foreign_key "daily_progs", "goals" + add_foreign_key "goals", "users" add_foreign_key "task_progs", "daily_progs" add_foreign_key "task_progs", "tasks" add_foreign_key "tasks", "goals" From 32e3f29c19e59ce0c22ddada73844f27de5f8566 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 09:57:52 -0700 Subject: [PATCH 05/16] update to reflect goal user relationship --- app/models/user.rb | 13 +++++++++++++ app/services/prog_service.rb | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9f1c75b..9de50e7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,4 +5,17 @@ class User < ApplicationRecord format: { with: URI::MailTo::EMAIL_REGEXP } # <-- validates that the email is in correct format, and that it is unique passwordless_with :email # <-- tells Passwordless which field stores the email address + + def current_goal + goals.order(created_at: :desc).first || create_default_goal + end + + private + + def create_default_goal + goals.create!( + start_date: Date.current, + end_date: Date.current + 182.days + ) + end end diff --git a/app/services/prog_service.rb b/app/services/prog_service.rb index 5f6a25d..4989843 100644 --- a/app/services/prog_service.rb +++ b/app/services/prog_service.rb @@ -1,7 +1,6 @@ class ProgService def self.initialize_progs - goal = Goal.last.presence || Goal.create!(start_date: Date.current) - daily_prog = DailyProg.find_or_initialize_by(goal: goal, date: Date.current) - daily_prog.save! if daily_prog.new_record? + goal = current_user.current_goal + DailyProg.create_or_find_by!(goal: goal, date: Date.current) end end From 146ee7790b89d24eb9c0cc60b3e476c014ec3a34 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 11:04:58 -0700 Subject: [PATCH 06/16] remove example --- app/controllers/inertia_example_controller.rb | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 app/controllers/inertia_example_controller.rb diff --git a/app/controllers/inertia_example_controller.rb b/app/controllers/inertia_example_controller.rb deleted file mode 100644 index f4a6214..0000000 --- a/app/controllers/inertia_example_controller.rb +++ /dev/null @@ -1,26 +0,0 @@ -class InertiaExampleController < ApplicationController - def index - Counter.create do |counter| - counter.click = 1 - end if Counter.find_by_id(1).nil? - - render inertia: "InertiaExample", props: { - name: params.fetch(:name, "Planet"), - count: Counter.last.click - } - end - - def increase_counter - puts params - counter = Counter.find(1) - counter.click = params["count"].to_int - counter.save! - - render inertia: "InertiaExample", props: { - name: params.fetch(:name, "howdy"), - count: 89 - } - rescue StandardError => e - Rails.logger.info e - end -end From 56f38d4eb4da29ba8bb794d7cd553f469542b404 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 11:59:10 -0700 Subject: [PATCH 07/16] move to concern --- app/controllers/application_controller.rb | 9 -------- app/controllers/authenticated_controller.rb | 1 + app/controllers/concerns/goal_scoped.rb | 25 +++++++++++++++++++++ app/services/prog_service.rb | 6 ----- 4 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 app/controllers/concerns/goal_scoped.rb delete mode 100644 app/services/prog_service.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d7cac0..7f4c7e5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,19 +1,10 @@ class ApplicationController < ActionController::Base include Passwordless::ControllerHelpers # <-- This! - before_action :initialize_progs helper_method :current_user private - def initialize_progs - today = Date.current.to_s - return if session[:initialize_progs] == today - - ProgService.initialize_progs - session[:initialize_progs] = today - end - def current_user @current_user ||= authenticate_by_session(User) end diff --git a/app/controllers/authenticated_controller.rb b/app/controllers/authenticated_controller.rb index 7eb5c40..a2ba27c 100644 --- a/app/controllers/authenticated_controller.rb +++ b/app/controllers/authenticated_controller.rb @@ -1,3 +1,4 @@ class AuthenticatedController < ApplicationController + include GoalScoped before_action :require_user! end diff --git a/app/controllers/concerns/goal_scoped.rb b/app/controllers/concerns/goal_scoped.rb new file mode 100644 index 0000000..2cf64ae --- /dev/null +++ b/app/controllers/concerns/goal_scoped.rb @@ -0,0 +1,25 @@ +module GoalScoped + extend ActiveSupport::Concern + + included do + before_action :set_current_goal + before_action :ensure_daily_prog + end + + private + + def set_current_goal + @current_goal = current_user.current_goal + end + + def ensure_daily_prog + today = Date.current.to_s + return if session[:initialize_progs] == today + + DailyProg.create_or_find_by!( + goal: @current_goal, + date: Date.current + ) + session[:initialize_progs] = today + end +end diff --git a/app/services/prog_service.rb b/app/services/prog_service.rb deleted file mode 100644 index 4989843..0000000 --- a/app/services/prog_service.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ProgService - def self.initialize_progs - goal = current_user.current_goal - DailyProg.create_or_find_by!(goal: goal, date: Date.current) - end -end From 0549d1e00f257232213acd5816822ae965fdfebc Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 11:59:57 -0700 Subject: [PATCH 08/16] rename controllers --- app/controllers/progress_controller.rb | 7 +++++++ app/controllers/progress_page_controller.rb | 5 ----- app/controllers/sessions/login_page_controller.rb | 5 ----- ..._page_controller.rb => settings_controller.rb} | 2 +- config/routes.rb | 15 ++++++--------- 5 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 app/controllers/progress_controller.rb delete mode 100644 app/controllers/progress_page_controller.rb delete mode 100644 app/controllers/sessions/login_page_controller.rb rename app/controllers/{settings_page_controller.rb => settings_controller.rb} (91%) diff --git a/app/controllers/progress_controller.rb b/app/controllers/progress_controller.rb new file mode 100644 index 0000000..46ef6a4 --- /dev/null +++ b/app/controllers/progress_controller.rb @@ -0,0 +1,7 @@ +class ProgressController < AuthenticatedController + def index + daily_progs = @current_goal.daily_progs + start_date = @current_goal.start_date + render inertia: 'ProgressPage', props: { progs: daily_progs, startdate: start_date } + end +end diff --git a/app/controllers/progress_page_controller.rb b/app/controllers/progress_page_controller.rb deleted file mode 100644 index 900127c..0000000 --- a/app/controllers/progress_page_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ProgressPageController < AuthenticatedController - def index - render inertia: 'ProgressPage', props: { progs: Goal.last.daily_progs, startdate: Goal.last.start_date } - end -end diff --git a/app/controllers/sessions/login_page_controller.rb b/app/controllers/sessions/login_page_controller.rb deleted file mode 100644 index 30d0964..0000000 --- a/app/controllers/sessions/login_page_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Sessions::LoginPageController < ApplicationController - def index - render inertia: 'LoginPage', props: { prop: 'random' } - end -end diff --git a/app/controllers/settings_page_controller.rb b/app/controllers/settings_controller.rb similarity index 91% rename from app/controllers/settings_page_controller.rb rename to app/controllers/settings_controller.rb index af53185..b61cb39 100644 --- a/app/controllers/settings_page_controller.rb +++ b/app/controllers/settings_controller.rb @@ -1,4 +1,4 @@ -class SettingsPageController < AuthenticatedController +class SettingsController < AuthenticatedController def index tasks = TaskService.fetch_today_tasks render inertia: 'SettingsPage', props: { tasks: tasks } diff --git a/config/routes.rb b/config/routes.rb index b2a864b..f81c7ab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,21 +1,18 @@ Rails.application.routes.draw do passwordless_for :users, controller: 'sessions' # Defines the root path route ("/") - root 'settings_page#index' + root 'settings#index' - get 'settings', to: 'settings_page#index' - post 'settings', to: 'settings_page#bulk_update' + get 'settings', to: 'settings#index' + post 'settings', to: 'settings#bulk_update' get 'today', to: 'tasks/today#index' patch 'today', to: 'tasks/today#edit' - get 'progress', to: 'progress_page#index' + get 'progress', to: 'progress#index' - get 'inertia-example', to: 'inertia_example#index' - post 'inertia-example', to: 'inertia_example#increase_counter' - - get 'login', to: 'sessions/login_page#index' - post 'login', to: 'sessions/login_page#create' + get 'login', to: 'sessions#index' + post 'login', to: 'sessions#create' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. From d26ec0a120bc1752acb3d67615087ae6b8959b68 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 11 May 2025 12:00:25 -0700 Subject: [PATCH 09/16] inertiable --- app/controllers/sessions_controller.rb | 14 ++++++++++++++ app/controllers/users_controller.rb | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 2268403..ee5cbfc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,6 +1,20 @@ class SessionsController < Passwordless::SessionsController before_action :require_unauth!, only: %i[new show] + def index + render inertia: 'LoginPage', props: { prop: 'random' } + end + + def new + render inertia: 'LoginPage', props: { prop: 'random' } + end + + def show + render inertia: 'LoginPage', props: { prop: 'random' } + end + + def create; end + private def require_unauth! diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 72fa659..6110e58 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,9 +4,15 @@ def create if @user.save sign_in(create_passwordless_session(@user)) # <-- This! - redirect_to(@user, flash: { notice: 'Welcome!' }) + redirect_to root_path, intertia: { props: { message: 'Welcome!' } } else - render(:new) + redirect_to login_path, inertia: { + props: { + message: 'nah!', + errors: @user.errors, + user: @user + } + }, status: :unprocessable_entity end end end From d7747257292f489f6b9f57cda6bb837d36c6b3d6 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 12 May 2025 08:35:34 -0700 Subject: [PATCH 10/16] fix deleting users --- app/models/goal.rb | 2 ++ app/models/user.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/goal.rb b/app/models/goal.rb index aa66d7f..d4c1c3a 100644 --- a/app/models/goal.rb +++ b/app/models/goal.rb @@ -1,4 +1,6 @@ class Goal < ApplicationRecord + belongs_to :user + has_many :tasks, dependent: :destroy has_many :daily_progs, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 9de50e7..80bc39d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,6 +6,8 @@ class User < ApplicationRecord passwordless_with :email # <-- tells Passwordless which field stores the email address + has_many :goals, dependent: :destroy + def current_goal goals.order(created_at: :desc).first || create_default_goal end From f4be0ef6f0e30a0546c63e37d13f7de5c55b0902 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 12 May 2025 08:35:58 -0700 Subject: [PATCH 11/16] move to sessionscontroller --- app/controllers/sessions_controller.rb | 17 ++++++++++++++++- config/routes.rb | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ee5cbfc..ed8c38b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -13,7 +13,22 @@ def show render inertia: 'LoginPage', props: { prop: 'random' } end - def create; end + def create + @user = User.new(email: params[:email]) + + if @user.save + sign_in(create_passwordless_session(@user)) # <-- This! + redirect_to root_path, intertia: { props: { message: 'Welcome!' } } + else + redirect_to login_path, inertia: { + props: { + message: 'nah!', + errors: @user.errors, + user: @user + } + }, status: :unprocessable_entity + end + end private diff --git a/config/routes.rb b/config/routes.rb index f81c7ab..454f1f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - passwordless_for :users, controller: 'sessions' + passwordless_for :users, at: '/', controller: 'sessions', as: :user_session # Defines the root path route ("/") root 'settings#index' From 2f2b6aec25aa91cb73b11c944836a8e720a52cda Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 12 May 2025 08:36:42 -0700 Subject: [PATCH 12/16] begin adding mailer --- Gemfile | 1 + Gemfile.lock | 9 +++++++++ app/controllers/application_controller.rb | 1 - app/mailers/application_mailer.rb | 4 ++-- config/environments/development.rb | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index a9bb41a..729b30e 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,7 @@ group :development do # gem "spring" gem 'error_highlight', '>= 0.4.0', platforms: [:ruby] + gem 'letter_opener' gem 'pry-byebug' gem 'solargraph', require: false gem 'solargraph-rails', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 60687b2..86c9db4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,6 +101,8 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (5.1.0) + logger (~> 1.5) coderay (1.1.3) concurrent-ruby (1.3.3) connection_pool (2.4.1) @@ -144,6 +146,12 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.4) + launchy (3.1.1) + addressable (~> 2.8) + childprocess (~> 5.0) + logger (~> 1.6) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) @@ -359,6 +367,7 @@ DEPENDENCIES error_highlight (>= 0.4.0) inertia_rails-contrib (~> 0.1.1) jbuilder + letter_opener passwordless pg (~> 1.1) pry-byebug diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f4c7e5..9dddebb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,7 +10,6 @@ def current_user end def require_user! - return if Rails.env.development? return if current_user save_passwordless_redirect_location!(User) # <-- optional, see below diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c81..286b223 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" - layout "mailer" + default from: 'from@example.com' + layout 'mailer' end diff --git a/config/environments/development.rb b/config/environments/development.rb index 2e7fb48..d6c8f35 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -73,4 +73,8 @@ # Raise error when a before_action's only/except options reference missing actions config.action_controller.raise_on_missing_callback_actions = true + + # mailer + config.action_mailer.delivery_method = :letter_opener + config.action_mailer.perform_deliveries = true end From 745866aed79175c0f512b1abf8ec0cf62349ba52 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Mon, 12 May 2025 08:37:02 -0700 Subject: [PATCH 13/16] test login page --- app/frontend/pages/LoginPage.vue | 57 ++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/app/frontend/pages/LoginPage.vue b/app/frontend/pages/LoginPage.vue index e128115..7fc0f09 100644 --- a/app/frontend/pages/LoginPage.vue +++ b/app/frontend/pages/LoginPage.vue @@ -1,5 +1,58 @@ + + From 0e46933af8aff9838a149b7fa1a6625f1bf91656 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 24 Aug 2025 17:16:38 -0700 Subject: [PATCH 14/16] feat: auto-sign in user after successful registration --- app/controllers/application_controller.rb | 11 +++++-- app/controllers/authenticated_controller.rb | 4 --- app/controllers/progress_controller.rb | 3 +- app/controllers/sessions_controller.rb | 33 ++++---------------- app/controllers/settings_controller.rb | 5 +-- app/controllers/tasks/today_controller.rb | 4 +-- app/controllers/users_controller.rb | 34 +++++++++++++++------ app/services/task_service.rb | 4 +-- config/application.rb | 2 ++ config/environments/development.rb | 3 ++ config/initializers/passwordless.rb | 10 ++++++ config/locales/en.yml | 6 +++- config/routes.rb | 10 +++--- 13 files changed, 73 insertions(+), 56 deletions(-) delete mode 100644 app/controllers/authenticated_controller.rb create mode 100644 config/initializers/passwordless.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9dddebb..695e406 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,18 +1,25 @@ class ApplicationController < ActionController::Base include Passwordless::ControllerHelpers # <-- This! + before_action :require_user helper_method :current_user + inertia_share auth: lambda { + { user: current_user && { email: current_user.email, id: current_user.id } } + }, flash: lambda { + { notice: flash.notice, alert: flash.alert } + } + private def current_user @current_user ||= authenticate_by_session(User) end - def require_user! + def require_user return if current_user save_passwordless_redirect_location!(User) # <-- optional, see below - redirect_to login_path, inertia: { props: { random_prop: 'prop' } } + redirect_to users_sign_in_path, inertia: { props: { random_prop: 'prop' } } end end diff --git a/app/controllers/authenticated_controller.rb b/app/controllers/authenticated_controller.rb deleted file mode 100644 index a2ba27c..0000000 --- a/app/controllers/authenticated_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class AuthenticatedController < ApplicationController - include GoalScoped - before_action :require_user! -end diff --git a/app/controllers/progress_controller.rb b/app/controllers/progress_controller.rb index 46ef6a4..b4d3d0f 100644 --- a/app/controllers/progress_controller.rb +++ b/app/controllers/progress_controller.rb @@ -1,4 +1,5 @@ -class ProgressController < AuthenticatedController +class ProgressController < ApplicationController + include GoalScoped def index daily_progs = @current_goal.daily_progs start_date = @current_goal.start_date diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ed8c38b..b56fbf1 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,40 +1,19 @@ class SessionsController < Passwordless::SessionsController - before_action :require_unauth!, only: %i[new show] - - def index - render inertia: 'LoginPage', props: { prop: 'random' } - end + skip_before_action :require_user def new render inertia: 'LoginPage', props: { prop: 'random' } end def show - render inertia: 'LoginPage', props: { prop: 'random' } - end - - def create - @user = User.new(email: params[:email]) - - if @user.save - sign_in(create_passwordless_session(@user)) # <-- This! - redirect_to root_path, intertia: { props: { message: 'Welcome!' } } - else - redirect_to login_path, inertia: { - props: { - message: 'nah!', - errors: @user.errors, - user: @user - } - }, status: :unprocessable_entity - end + super + # IMPORTANT: call super to let Passwordless validate token & sign in. + render inertia: 'TokenPage' end private - def require_unauth! - return unless current_user - - redirect_to('/', notice: 'You are already signed in.') + def redirect_path_after_failed_sign_in + users_sign_in_path end end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index b61cb39..517de1f 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -1,6 +1,7 @@ -class SettingsController < AuthenticatedController +class SettingsController < ApplicationController + include GoalScoped def index - tasks = TaskService.fetch_today_tasks + tasks = TaskService.fetch_today_tasks(current_user) render inertia: 'SettingsPage', props: { tasks: tasks } end diff --git a/app/controllers/tasks/today_controller.rb b/app/controllers/tasks/today_controller.rb index 1eee579..bd3cd88 100644 --- a/app/controllers/tasks/today_controller.rb +++ b/app/controllers/tasks/today_controller.rb @@ -1,5 +1,5 @@ module Tasks - class TodayController < AuthenticatedController + class TodayController < ApplicationController def index render inertia: 'TodayPage', props: { tasks: collection } rescue StandardError => e @@ -20,7 +20,7 @@ def edit private def collection - @collection ||= TaskService.fetch_today_tasks.select { |task| task[:text].present? } + @collection ||= TaskService.fetch_today_tasks(current_user).select { |task| task[:text].present? } end def resource diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6110e58..ea03d99 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,18 +1,34 @@ class UsersController < ApplicationController + skip_before_action :require_user, only: %i[new create] + + def new + if current_user + redirect_to root_path + else + render inertia: 'SignUpPage', props: { username: '', email: '', errors: {} } + end + end + def create - @user = User.new(user_params) + @user = User.new(resource_params) if @user.save + # pwless_session = build_passwordless_session(@user) + # pwless_session.save! + # Passwordless::Mailer.sign_in(pwless_session, pwless_session.token).deliver_later + # redirect_to users_sign_in_path(token: pwless_session.token) sign_in(create_passwordless_session(@user)) # <-- This! - redirect_to root_path, intertia: { props: { message: 'Welcome!' } } + redirect_to root_path, notice: "Welcome!" else - redirect_to login_path, inertia: { - props: { - message: 'nah!', - errors: @user.errors, - user: @user - } - }, status: :unprocessable_entity + render( + inertia: 'SignUpPage', + props: { username: @user.username, email: @user.email, errors: @user.errors.to_hash }, + status: :unprocessable_entity + ) end end + + def resource_params + params.require(:user).permit(:username, :email) + end end diff --git a/app/services/task_service.rb b/app/services/task_service.rb index b102472..ae13106 100644 --- a/app/services/task_service.rb +++ b/app/services/task_service.rb @@ -1,6 +1,6 @@ class TaskService - def self.fetch_today_tasks - goal = Goal.last + def self.fetch_today_tasks(user) + goal = user.current_goal goal.tasks.decorate.map(&:as_json_for_today) end end diff --git a/config/application.rb b/config/application.rb index 23c1e10..a356d88 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,5 +23,7 @@ class Application < Rails::Application # config.time_zone = 'Eastern Time (US & Canada)' # config.eager_load_paths << Rails.root.join("extras") + config.action_mailer.default_url_options = { host: 'localhost:3000' } + routes.default_url_options[:host] ||= 'localhost:3000' end end diff --git a/config/environments/development.rb b/config/environments/development.rb index d6c8f35..3abcc51 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -77,4 +77,7 @@ # mailer config.action_mailer.delivery_method = :letter_opener config.action_mailer.perform_deliveries = true + config.action_mailer.default_url_options = { host: 'localhost:3000' } + routes.default_url_options[:host] ||= 'localhost:3000' + config.action_mailer.raise_delivery_errors = true end diff --git a/config/initializers/passwordless.rb b/config/initializers/passwordless.rb new file mode 100644 index 0000000..8ea5c55 --- /dev/null +++ b/config/initializers/passwordless.rb @@ -0,0 +1,10 @@ +Passwordless.configure do |config| + config.after_session_save = lambda do |session, request| + # Default behavior is + Rails.logger.info "Attempting to send passwordless email for session: #{session.inspect}" + Passwordless::Mailer.sign_in(session).deliver_now + + # You can change behavior to do something with session model. For example, + # SmsApi.send_sms(session.authenticatable.phone_number, session.token) + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 6c349ae..9bfc5e7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,4 +28,8 @@ # enabled: "ON" en: - hello: "Hello world" + passwordless: + mailer: + sign_in: + subject: "Sign in to Do Five Things" + body: "Click the link below to sign in to Do Five Things:\n\n%{magic_link}\n\nOr enter this code: %{token}\n\nThis link will expire in 15 minutes." diff --git a/config/routes.rb b/config/routes.rb index 454f1f0..23eb80a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,18 +1,16 @@ Rails.application.routes.draw do - passwordless_for :users, at: '/', controller: 'sessions', as: :user_session + passwordless_for :users, controller: 'sessions' + + get 'sign_up', to: 'users#new', as: :sign_up + post 'sign_up', to: 'users#create' # Defines the root path route ("/") root 'settings#index' - get 'settings', to: 'settings#index' post 'settings', to: 'settings#bulk_update' - get 'today', to: 'tasks/today#index' patch 'today', to: 'tasks/today#edit' - get 'progress', to: 'progress#index' - get 'login', to: 'sessions#index' - post 'login', to: 'sessions#create' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. From accf4320e9816482460669f2e9358af29ff0a6c5 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 24 Aug 2025 17:21:29 -0700 Subject: [PATCH 15/16] adjust applicationmailer --- app/mailers/application_mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..0bca67c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' + default from: 'support@dofivethings.com' layout 'mailer' end From d85860a8147d63c1d468ee0992e824eb282f0ce6 Mon Sep 17 00:00:00 2001 From: mashiinka Date: Sun, 24 Aug 2025 17:27:38 -0700 Subject: [PATCH 16/16] remove --- app/frontend/pages/LoginPage.vue | 58 ------------------- app/views/passwordless/sessions/new.html.erb | 12 ---- app/views/passwordless/sessions/show.html.erb | 8 --- app/views/sessions/new.html.erb | 21 ------- 4 files changed, 99 deletions(-) delete mode 100644 app/frontend/pages/LoginPage.vue delete mode 100644 app/views/passwordless/sessions/new.html.erb delete mode 100644 app/views/passwordless/sessions/show.html.erb delete mode 100644 app/views/sessions/new.html.erb diff --git a/app/frontend/pages/LoginPage.vue b/app/frontend/pages/LoginPage.vue deleted file mode 100644 index 7fc0f09..0000000 --- a/app/frontend/pages/LoginPage.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - diff --git a/app/views/passwordless/sessions/new.html.erb b/app/views/passwordless/sessions/new.html.erb deleted file mode 100644 index 831e45c..0000000 --- a/app/views/passwordless/sessions/new.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= form_with(model: @session, url: url_for(action: 'new'), data: { turbo: 'false' }) do |f| %> - <% email_field_name = :"passwordless[#{email_field}]" %> - <%= f.label email_field_name, - t("passwordless.sessions.new.email.label"), - for: "passwordless_#{email_field}" %> - <%= email_field_tag email_field_name, - params.fetch(email_field_name, nil), - required: true, - autofocus: true, - placeholder: t("passwordless.sessions.new.email.placeholder") %> - <%= f.submit t("passwordless.sessions.new.submit") %> -<% end %> diff --git a/app/views/passwordless/sessions/show.html.erb b/app/views/passwordless/sessions/show.html.erb deleted file mode 100644 index 5ebb0e7..0000000 --- a/app/views/passwordless/sessions/show.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= form_with(model: @session, url: url_for(action: 'update'), scope: 'passwordless', method: 'patch', data: { turbo: false }) do |f| %> - <%= f.label :token, t(".token") %> - <%= f.text_field :token, - required: true, - autofocus: true, - autocomplete: "one-time-code" %> - <%= f.submit t(".confirm") %> -<% end %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb deleted file mode 100644 index 84f9afe..0000000 --- a/app/views/sessions/new.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
-

- Sign in to your account -

-
- <%= form_with(model: @session, url: login_path, class: "mt-8 space-y-6") do |f| %> -
-
- <%= f.label :email, class: "sr-only" %> - <%= f.email_field :email, required: true, class: "appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm", placeholder: "Email address" %> -
-
- -
- <%= f.submit "Send magic link", class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %> -
- <% end %> -
-