Migrate to Rais 8.0
- Remove all Rodauth stuff and implement simple custom auth - Migrate from sprockets to propshaft, hack some bootstrap stuff
This commit is contained in:
parent
0198a22278
commit
c35c7da6e0
66 changed files with 518 additions and 684 deletions
24
app/controllers/sessions_controller.rb
Normal file
24
app/controllers/sessions_controller.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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." }
|
||||
|
||||
def new
|
||||
redirect_to :root if authenticated?
|
||||
end
|
||||
|
||||
def create
|
||||
redirect_to :root if authenticated?
|
||||
|
||||
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."
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
terminate_session
|
||||
redirect_to new_session_path
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue