Class: Passwordless::SessionsController
Instance Method Summary
collapse
#authenticate_by_cookie, #sign_in, #sign_out
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/passwordless/sessions_controller.rb', line 15
def create
email_field = authenticatable_class.passwordless_email_field
authenticatable = authenticatable_class.where(
"lower(#{email_field}) = ?", params[:passwordless][email_field]
).first
session = Session.new.tap do |us|
us.remote_addr = request.remote_addr
us.user_agent = request.env['HTTP_USER_AGENT']
us.authenticatable = authenticatable
end
if session.save
Mailer.magic_link(session).deliver_now
end
render
end
|
#destroy ⇒ Object
48
49
50
51
|
# File 'app/controllers/passwordless/sessions_controller.rb', line 48
def destroy
sign_out authenticatable_class
redirect_to main_app.root_path
end
|
#new ⇒ Object
9
10
11
12
13
|
# File 'app/controllers/passwordless/sessions_controller.rb', line 9
def new
@email_field = authenticatable_class.passwordless_email_field
@session = Session.new
end
|
#show ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/passwordless/sessions_controller.rb', line 34
def show
BCrypt::Password.create(params[:token])
session = Session.valid.find_by!(
authenticatable_type: authenticatable_classname,
token: params[:token]
)
sign_in session.authenticatable
redirect_to main_app.root_path
end
|