1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/controllers/users/sessions_controller.rb

41 lines
756 B
Ruby
Raw Normal View History

2018-11-29 16:28:20 -05:00
# frozen_string_literal: true
class Users::SessionsController < Devise::SessionsController
2019-02-01 20:34:11 -05:00
# TODO: do not skip
skip_after_action :verify_authorized, only: :create
2018-11-30 06:23:40 -05:00
2018-12-13 21:13:49 -05:00
prepend_before_action :check_captcha, only: :create
2018-11-29 16:28:20 -05:00
# GET /resource/sign_in
2018-12-14 00:00:19 -05:00
def new
2019-02-01 20:34:11 -05:00
authorize %i[users session]
2018-12-14 00:00:19 -05:00
super
end
2018-11-29 16:28:20 -05:00
# POST /resource/sign_in
2018-12-13 21:13:49 -05:00
def create
2019-09-03 09:52:49 -04:00
super do |user|
2019-09-10 00:42:26 -04:00
LogUserSessionJob.perform_later user.id, request.user_agent
2019-09-03 09:52:49 -04:00
end
2018-12-13 21:13:49 -05:00
end
2018-11-29 16:28:20 -05:00
# DELETE /resource/sign_out
2018-12-13 21:13:49 -05:00
def destroy
2019-02-01 20:34:11 -05:00
authorize %i[users session]
2019-07-18 23:04:16 -04:00
super
2018-12-13 21:13:49 -05:00
end
2018-11-29 16:28:20 -05:00
2018-12-13 21:13:49 -05:00
protected
2018-11-29 16:28:20 -05:00
2018-12-13 21:13:49 -05:00
def check_captcha
return if verify_recaptcha
self.resource = resource_class.new sign_in_params
render :new
end
2019-03-23 20:48:37 -04:00
def verify_signed_out_user
super if current_account.nil?
end
2018-11-29 16:28:20 -05:00
end