diff --git a/app/admin/user.rb b/app/admin/user.rb index dacf86b1..565c205a 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -21,15 +21,22 @@ ActiveAdmin.register User do f.input :email f.input :firstname f.input :lastname - f.input :password - f.input :password_confirmation end f.actions end + controller do def permitted_params - params.permit admin_user: %i[login email firstname lastname password - password_confirmation] + params.permit user: %i[login email firstname lastname] end end + + before_create do |user| + user.password = Devise.friendly_token.first(8) + end + + after_create do |user| + logger.info 'Sending initialisation mail to moderator' + user.send_reset_password_instructions + end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 605738cf..fb634591 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # The top level controller, where can be centralised almost everything class ApplicationController < ActionController::Base - before_action :set_paper_trail_whodunnit, :set_locale, :discard - before_action :set_mailer_host, if: :devise_controller? + before_action :set_paper_trail_whodunnit, :set_locale, :discard, + :set_mailer_host before_action :configure_permitted_parameters, if: :devise_controller? # Prevent CSRF attacks by raising an exception. diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index d6a800f9..73afe3a0 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -9,7 +9,6 @@ class EventsController < ApplicationController before_action :set_event, except: %i[index new preview_create create] before_action :set_create_event, only: %i[new preview_create create] before_action :check_secret, only: %i[edit preview update destroy] - before_action :set_mailer_host, only: %i[create update destroy] rescue_from ActiveRecord::StaleObjectError, with: :locked def index diff --git a/app/controllers/moderations_controller.rb b/app/controllers/moderations_controller.rb index d733d4e1..f8d6aed4 100644 --- a/app/controllers/moderations_controller.rb +++ b/app/controllers/moderations_controller.rb @@ -4,7 +4,7 @@ class ModerationsController < ApplicationController has_scope :near, type: :hash, using: %i[location distance] before_action :authenticate_user! - before_action :set_moderation, :set_mailer_host, only: + before_action :set_moderation, only: %i[show edit preview update validate accept refuse destroy] before_action :generate_destroy_reason, only: :destroy rescue_from ActiveRecord::StaleObjectError, with: :locked @@ -14,6 +14,14 @@ class ModerationsController < ApplicationController @orgas = Orga.unmoderated end + def show; end + + def edit; end + + def validate; end + + def refuse; end + def preview @moderation.attributes = moderation_params @moderation.valid? diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index de2e2852..4c0e22c2 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,7 +1,7 @@ # Events, particulary during moderation, can have notes associated to them class NotesController < ApplicationController before_action :set_event, only: %i[new create] - before_action :create_note, :set_mailer_host, only: %i[create] + before_action :create_note, only: %i[create] # GET /moderations/id/new def new diff --git a/app/controllers/orgas_controller.rb b/app/controllers/orgas_controller.rb index f41d5878..4c73e768 100644 --- a/app/controllers/orgas_controller.rb +++ b/app/controllers/orgas_controller.rb @@ -5,7 +5,6 @@ class OrgasController < ApplicationController has_scope :active, type: :boolean, default: true, allow_blank: true before_action :set_orga, except: %i[index new create] - before_action :set_mailer_host before_action :authenticate_user!, except: %i[index new create show], unless: :check_secret diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 74746087..353874d6 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -3,7 +3,7 @@ .field.login = f.label :login %br/ - = f.email_field :login, autofocus: true, autocomplete: "login" + = f.text_field :login, autofocus: true, autocomplete: "login" .field.password = f.label :password %br/ diff --git a/config/routes.rb b/config/routes.rb index 19249352..0f85ad1b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,7 +43,8 @@ Rails.application.routes.draw do devise_for :users, skip: [:registrations] as :user do - get 'users/edit' => 'devise/registrations#edit', as: 'edit_user_registration' + get 'users/edit' => 'devise/registrations#edit', + as: 'edit_user_registration' put 'users' => 'devise/registrations#update', as: 'user_registration' end devise_for :admin_users, ActiveAdmin::Devise.config