diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 54e31276..f5c8f31c 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -8,9 +8,29 @@ class Users::RegistrationsController < Devise::RegistrationsController # end # POST /resource - # def create - # super - # end + def create + build_resource(sign_up_params) + + resource.save + yield resource if block_given? + if resource.persisted? + if resource.active_for_authentication? + set_flash_message! :notice, :signed_up + sign_up(resource_name, resource) + respond_with resource, location: after_sign_up_path_for(resource) + else + set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}" + expire_data_after_sign_in! + respond_with resource, location: after_inactive_sign_up_path_for(resource) + end + else + clean_up_passwords resource + set_minimum_password_length + resource.errors.full_messages.each {|x| flash[x] = x} # Rails 4 simple way + respond_with resource + #respond_with_navigational(resource) { render_with_scope :new } + end + end # GET /resource/edit # def edit diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index 1de4347b..544f7ad4 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -54,7 +54,8 @@
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %> + <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %> +
<%= f.label :email %> <%= f.email_field :email, autofocus: true, class: "form-control", id: "sign_up_email" %> diff --git a/config/routes.rb b/config/routes.rb index 0cd9b40c..991677a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,6 +29,10 @@ post 'download_material' => 'events#download_material', as: :download_material end resources :profiles, except: [:index, :destroy] + + devise_scope :user do + get "/users/sign_up" => redirect("/users/sign_in") + end devise_for :users, :controllers => {:registrations => "users/registrations"} resources :users, only: [:index] # index page for devise users patch 'users/:id/role' => 'users#update_role', as: :update_user_role