[Rails] Site internet de la World Tartiflette Tour.
1
classSessionsController<ApplicationController
2
allow_unauthenticated_access only: %i[ new create accept_cookies gift_nico ]
3
rate_limit to: 10, within: 3.minutes, only: :create, with: -> {redirect_to new_session_url, alert: "Try again later." }
4
5
defnew
6
end
7
8
defcreate
9
if user = User.authenticate_by(params.permit(:email_address, :password))
10
start_new_session_for user
11
if user.admin
12
session[:admin] = true
13
end
14
redirect_to after_authentication_url
15
else
16
redirect_to new_session_path, alert: "Try another email address or password."
17
end
18
end
19
20
defdestroy
21
terminate_session
22
redirect_to new_session_path
23
end
24
25
defdismiss_banner
26
session[:dismissed_banner] = true
27
redirect_to root_path
28
end
29
30
defaccept_cookies
31
session[:dismissed_banner] = true
32
redirect_to root_path
33
end
34
35
defgift_nico
36
session[:dismissed_banner] = true
37
redirect_to root_path
38
end
39
end
40