docbrown/app/controllers/internal/invitations_controller.rb
Ben Halpern da6a6739e5
[deploy] Invite users to join and create password (#9294)
* Initial invitation work

* Add more invitation code

* Add proper registration page

* Fix up tests

* Fix failings

* Fix spec

* Add self-serve auth config

* Add registered condition

* Change profile image call and registered_at test

* Change comment

* Fix copy test

* Stub emojipedia

* Linting

* Add registered at to factory

* Ensure registered for user tag

* Update app/views/internal/invitations/index.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/controllers/internal/invitations_controller.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Slight changes

* Update recover password flow

* Update app/views/internal/invitations/index.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/controllers/internal/invitations_controller.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update db/schema.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>
2020-07-15 11:37:19 -04:00

23 lines
686 B
Ruby

module Internal
class InvitationsController < Internal::ApplicationController
layout "internal"
def index
@invitations = User.where(registered: false).page(params[:page]).per(50)
end
def new; end
def create
email = params.dig(:user, :email)
name = params.dig(:user, :name)
username = "#{name.downcase.tr(' ', '_').gsub(/[^0-9a-z ]/i, '')}_#{rand(1000)}"
User.invite!(email: email,
name: name,
username: username,
remote_profile_image_url: Users::ProfileImageGenerator.call,
registered: false)
redirect_to internal_invitations_path
end
end
end