Class: Admin::InvitesController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::InvitesController
- Defined in:
- app/controllers/admin/invites_controller.rb
Instance Method Summary collapse
Instance Method Details
#accept ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#index ⇒ Object
11 12 13 |
# File 'app/controllers/admin/invites_controller.rb', line 11 def index redirect_to admin_users_url end |
#new ⇒ Object
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 |
#show ⇒ Object
25 26 27 |
# File 'app/controllers/admin/invites_controller.rb', line 25 def show @user = User.new(email: @invite.email) end |