Install Rails' authentication generator #142
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
identified_by :current_user
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
module Authentication
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class PasswordsController < ApplicationController
|
||||
allow_unauthenticated_access
|
||||
before_action :set_user_by_token, only: %i[ edit update ]
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class SessionsController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[ new create ]
|
||||
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class PasswordsMailer < ApplicationMailer
|
||||
def reset(user)
|
||||
@user = user
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class Current < ActiveSupport::CurrentAttributes
|
||||
attribute :session
|
||||
delegate :user, to: :session, allow_nil: true
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: sessions
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: users
|
||||
|
@ -1,3 +1,5 @@
|
||||
<%# Copyright (C) 2024 Manuel Bustillo %>
|
||||
|
||||
<h1>Update your password</h1>
|
||||
|
||||
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
||||
|
@ -1,3 +1,5 @@
|
||||
<%# Copyright (C) 2024 Manuel Bustillo %>
|
||||
|
||||
<h1>Forgot your password?</h1>
|
||||
|
||||
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
||||
|
@ -1,3 +1,5 @@
|
||||
<%# Copyright (C) 2024 Manuel Bustillo %>
|
||||
|
||||
<p>
|
||||
You can reset your password within the next 15 minutes on
|
||||
<%= link_to "this password reset page", edit_password_url(@user.password_reset_token) %>.
|
||||
|
@ -1,2 +1,4 @@
|
||||
<%# Copyright (C) 2024 Manuel Bustillo %>
|
||||
|
||||
You can reset your password within the next 15 minutes on this password reset page:
|
||||
<%= edit_password_url(@user.password_reset_token) %>
|
||||
|
@ -1,3 +1,5 @@
|
||||
<%# Copyright (C) 2024 Manuel Bustillo %>
|
||||
|
||||
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
||||
<%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class CreateUsers < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class CreateSessions < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :sessions do |t|
|
||||
|
2
db/schema.rb
generated
2
db/schema.rb
generated
@ -1,3 +1,5 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
|
Loading…
x
Reference in New Issue
Block a user