Added Rubocop and initial config
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PasswordsController < ApplicationController
|
||||
allow_unauthenticated_access
|
||||
before_action :set_user_by_token, only: %i[ edit update ]
|
||||
before_action :set_user_by_token, only: %i[edit update]
|
||||
|
||||
def new
|
||||
end
|
||||
def new; end
|
||||
|
||||
def create
|
||||
if user = User.find_by(email_address: params[:email_address])
|
||||
PasswordsMailer.reset(user).deliver_later
|
||||
end
|
||||
|
||||
redirect_to new_session_path, notice: "Password reset instructions sent (if user with that email address exists)."
|
||||
redirect_to new_session_path, notice: 'Password reset instructions sent (if user with that email address exists).'
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -18,16 +19,17 @@ class PasswordsController < ApplicationController
|
||||
|
||||
def update
|
||||
if @user.update(params.permit(:password, :password_confirmation))
|
||||
redirect_to new_session_path, notice: "Password has been reset."
|
||||
redirect_to new_session_path, notice: 'Password has been reset.'
|
||||
else
|
||||
redirect_to edit_password_path(params[:token]), alert: "Passwords did not match."
|
||||
redirect_to edit_password_path(params[:token]), alert: 'Passwords did not match.'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def set_user_by_token
|
||||
@user = User.find_by_password_reset_token!(params[:token])
|
||||
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
||||
redirect_to new_password_path, alert: "Password reset link is invalid or has expired."
|
||||
end
|
||||
|
||||
def set_user_by_token
|
||||
@user = User.find_by_password_reset_token!(params[:token])
|
||||
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
||||
redirect_to new_password_path, alert: 'Password reset link is invalid or has expired.'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ProjectsController < ApplicationController
|
||||
before_action :fetch_project!, only: %w[show edit update destroy]
|
||||
|
||||
@@ -5,8 +7,7 @@ class ProjectsController < ApplicationController
|
||||
@projects = Project.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def new
|
||||
@project = Project.new
|
||||
@@ -21,8 +22,7 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @project.update(project_params)
|
||||
@@ -32,8 +32,7 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
def destroy; end
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
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." }
|
||||
# frozen_string_literal: true
|
||||
|
||||
def new
|
||||
end
|
||||
class SessionsController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[new create]
|
||||
rate_limit to: 10, within: 3.minutes, only: :create, with: lambda {
|
||||
redirect_to new_session_url, alert: 'Try again later.'
|
||||
}
|
||||
|
||||
def new; end
|
||||
|
||||
def create
|
||||
if user = User.authenticate_by(params.permit(:email_address, :password))
|
||||
start_new_session_for user
|
||||
redirect_to after_authentication_url
|
||||
else
|
||||
redirect_to new_session_path, alert: "Try another email address or password."
|
||||
redirect_to new_session_path, alert: 'Try another email address or password.'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user