-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathuser_registrations_controller.rb
More file actions
46 lines (36 loc) · 1.16 KB
/
user_registrations_controller.rb
File metadata and controls
46 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true
class Spree::UserRegistrationsController < Devise::RegistrationsController
helper 'spree/base', 'spree/store'
include Spree::Core::ControllerHelpers::Auth
include Spree::Core::ControllerHelpers::Common
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::Store
include SolidusAuthDevise::DeprecatedRoutes
before_action :check_permissions, only: [:edit, :update]
skip_before_action :require_no_authentication
def create
build_resource(spree_user_params)
if resource.save
set_flash_message(:notice, :signed_up)
sign_in(:spree_user, resource)
session[:spree_user_signup] = true
respond_with resource, location: after_sign_up_path_for(resource)
else
clean_up_passwords(resource)
respond_with(resource) do |format|
format.html { render :new }
end
end
end
protected
def translation_scope
'devise.user_registrations'
end
def check_permissions
authorize!(:create, resource)
end
private
def spree_user_params
params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes | [:email])
end
end