Class: Admin::InvitesController
Instance Attribute Summary
#current_user
Instance Method Summary
collapse
#redirect, underscore
#policy, #verify_policy, #verify_policy_with_proc
inc_number_of_requests, original_title
#render_error
#authenticate!, #deauthenticate!, #logged_in?
Instance Method Details
#accept ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/admin/invites_controller.rb', line 13
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
|
#create ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/admin/invites_controller.rb', line 34
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
|
#destroy ⇒ Object
46
47
48
49
50
|
# File 'app/controllers/admin/invites_controller.rb', line 46
def destroy
flash[:notice] = "The invite to #{@invite.email} has been deleted"
@invite.destroy
redirect_to admin_invites_url
end
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/admin/invites_controller.rb', line 9
def index
redirect_to admin_users_url
end
|
#new ⇒ Object
27
28
29
30
31
32
|
# File 'app/controllers/admin/invites_controller.rb', line 27
def new
@invite = current_user.invites.new
Role.roles.each do |role|
@invite.roles.new(name: role.name) if role.default
end
end
|
#show ⇒ Object
23
24
25
|
# File 'app/controllers/admin/invites_controller.rb', line 23
def show
@user = User.new(email: @invite.email)
end
|