mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Centralize auth (#598)
This commit is contained in:
parent
b3c48d13e7
commit
0a0289846e
10 changed files with 13 additions and 14 deletions
|
@ -1,6 +1,5 @@
|
||||||
class AccountsController < ApplicationController
|
class AccountsController < ApplicationController
|
||||||
include Filterable
|
include Filterable
|
||||||
before_action :authenticate_user!
|
|
||||||
before_action :set_account, only: %i[ show update destroy sync ]
|
before_action :set_account, only: %i[ show update destroy sync ]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -2,7 +2,13 @@ module Authentication
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
helper_method :user_signed_in?
|
before_action :authenticate_user!
|
||||||
|
end
|
||||||
|
|
||||||
|
class_methods do
|
||||||
|
def skip_authentication(**options)
|
||||||
|
skip_before_action :authenticate_user!, **options
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -15,10 +21,6 @@ module Authentication
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_signed_in?
|
|
||||||
Current.user.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def login(user)
|
def login(user)
|
||||||
Current.user = user
|
Current.user = user
|
||||||
reset_session
|
reset_session
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
class PagesController < ApplicationController
|
class PagesController < ApplicationController
|
||||||
include Filterable
|
include Filterable
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def dashboard
|
def dashboard
|
||||||
snapshot = Current.family.snapshot(@period)
|
snapshot = Current.family.snapshot(@period)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class PasswordResetsController < ApplicationController
|
class PasswordResetsController < ApplicationController
|
||||||
|
skip_authentication
|
||||||
|
|
||||||
layout "auth"
|
layout "auth"
|
||||||
|
|
||||||
before_action :set_user_by_token, only: :update
|
before_action :set_user_by_token, only: :update
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class PasswordsController < ApplicationController
|
class PasswordsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class RegistrationsController < ApplicationController
|
class RegistrationsController < ApplicationController
|
||||||
|
skip_authentication
|
||||||
|
|
||||||
layout "auth"
|
layout "auth"
|
||||||
|
|
||||||
before_action :set_user, only: :create
|
before_action :set_user, only: :create
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class SessionsController < ApplicationController
|
class SessionsController < ApplicationController
|
||||||
|
skip_authentication only: %i[new create]
|
||||||
|
|
||||||
layout "auth"
|
layout "auth"
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class TransactionsController < ApplicationController
|
class TransactionsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
|
||||||
before_action :set_transaction, only: %i[ show edit update destroy ]
|
before_action :set_transaction, only: %i[ show edit update destroy ]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class ValuationsController < ApplicationController
|
class ValuationsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@account = Current.family.accounts.find(params[:account_id])
|
@account = Current.family.accounts.find(params[:account_id])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue