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