Class: Admin::InvitesController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/invites_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::StaticCacheController

#disable_static_cache!, #static_cached?

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::LocalesHelper

#content_locale

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#acceptObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/admin/invites_controller.rb', line 15

def accept
  @user = PagesCore::CreateUserService.call(user_params, invite: @invite)
  if @user.valid?
    authenticate!(@user)
    redirect_to admin_default_url
  else
    render action: :show
  end
end

#createObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/admin/invites_controller.rb', line 36

def create
  @invite = PagesCore::InviteService.call(invite_params,
                                          user: current_user,
                                          host: request.host,
                                          protocol: request.protocol)
  if @invite.valid?
    redirect_to admin_invites_url
  else
    render action: :new
  end
end

#destroyObject



48
49
50
51
52
# File 'app/controllers/admin/invites_controller.rb', line 48

def destroy
  flash[:notice] = "The invite to #{@invite.email} has been deleted"
  PagesCore::DestroyInviteService.call(invite: @invite)
  redirect_to admin_invites_url
end

#indexObject



11
12
13
# File 'app/controllers/admin/invites_controller.rb', line 11

def index
  redirect_to admin_users_url
end

#newObject



29
30
31
32
33
34
# File 'app/controllers/admin/invites_controller.rb', line 29

def new
  @invite = current_user.invites.new
  Role.roles.each do |role|
    @invite.roles.new(name: role.name) if role.default
  end
end

#showObject



25
26
27
# File 'app/controllers/admin/invites_controller.rb', line 25

def show
  @user = User.new(email: @invite.email)
end