11class SessionsController < ApplicationController
2- # FIXME: Remove this before launch!
3- unless Rails . env . local?
4- http_basic_authenticate_with \
5- name : Rails . application . credentials . account_signup_http_basic_auth . name ,
6- password : Rails . application . credentials . account_signup_http_basic_auth . password ,
7- realm : "Fizzy Signup" ,
8- only : :create , unless : -> { Identity . exists? ( email_address : email_address ) }
9- end
10-
112 disallow_account_scope
123 require_unauthenticated_access except : :destroy
134 rate_limit to : 10 , within : 3 . minutes , only : :create , with : -> { redirect_to new_session_path , alert : "Try again later." }
@@ -19,10 +10,11 @@ def new
1910
2011 def create
2112 if identity = Identity . find_by_email_address ( email_address )
22- handle_existing_user ( identity )
23- elsif
24- handle_new_signup
13+ magic_link = identity . send_magic_link
14+ flash [ :magic_link_code ] = magic_link &.code if Rails . env . development?
2515 end
16+
17+ redirect_to session_magic_link_path
2618 end
2719
2820 def destroy
@@ -34,16 +26,4 @@ def destroy
3426 def email_address
3527 params . expect ( :email_address )
3628 end
37-
38- def handle_existing_user ( identity )
39- magic_link = identity . send_magic_link
40- flash [ :magic_link_code ] = magic_link &.code if Rails . env . development?
41- redirect_to session_magic_link_path
42- end
43-
44- def handle_new_signup
45- Signup . new ( email_address : email_address ) . create_identity
46- session [ :return_to_after_authenticating ] = new_signup_completion_path
47- redirect_to session_magic_link_path
48- end
4929end
0 commit comments