Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F401884
invitations_controller.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Feb 20, 2:13 PM
Size
1 KB
Mime Type
text/x-ruby
Expires
Sat, Feb 22, 2:13 PM (19 h, 29 m)
Engine
blob
Format
Raw Data
Handle
191860
Attached To
rARCHIVING archiving
invitations_controller.rb
View Options
class
InvitationsController
<
ApplicationController
before_action
:fetch_invitation
,
only
:
[
:accept
]
# POST /invitations
def
create
invitation
=
Invitation
.
new
(
fetch_params
)
if
invitation
.
save
invitation
.
notify_user
flash
[
:success
]
=
"User
#{
invitation
.
user
.
username
}
has been invited to the client"
else
flash
[
:alert
]
=
'Invitation not created'
end
redirect_to
:back
end
# GET /invitations/:host_id/:verification_code
def
accept
return
redirect_to
root_path
unless
@invitation
host
=
@invitation
.
host
if
!
@invitation
.
host
.
users
.
include?
@invitation
.
user
if
@invitation
.
host
.
users
<<
@invitation
.
user
@invitation
.
destroy
end
else
@invitation
.
destroy
end
redirect_to
client_path
(
host
.
client
)
end
private
def
fetch_params
params
.
require
(
:invitation
)
.
permit
(
:user_id
,
:host_id
)
end
def
fetch_invitation
@invitation
=
Invitation
.
find_by
(
host_id
:
params
[
:host_id
]
,
verification_code
:
params
[
:verification_code
]
)
end
end
Event Timeline
Log In to Comment