Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F906934
application_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
Sat, Aug 30, 11:46 AM
Size
1 KB
Mime Type
text/x-ruby
Expires
Mon, Sep 1, 11:46 AM (1 d, 13 h)
Engine
blob
Format
Raw Data
Handle
253720
Attached To
rARCHIVING archiving
application_controller.rb
View Options
class
ApplicationController
<
ActionController
::
Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with
:
:exception
helper_method
:current_user
,
:warden
def
unauthenticated
redirect_to
root_path
end
# POST /login
def
login
if
params
[
:admin
]
==
'admin'
warden
.
authenticate
(
:admin
)
current_user
end
redirect_to
admin_path
end
def
logout
warden
.
logout
reset_current_user
redirect_to
root_path
end
protected
def
warden
request
.
env
[
'warden'
]
end
def
current_user
@current_user
||=
warden
.
user
end
def
reset_current_user
@current_user
=
nil
end
def
fetch_logs
days_ago
=
params
.
fetch
(
:days_back
,
7
)
.
to_i
rescue
7
if
@client
@logs
=
Log
.
includes
(
:job
)
.
joins
(
job
:
:client
)
.
where
(
Client
:
{
ClientId
:
@client
.
id
})
else
@logs
=
Log
.
includes
(
:job
)
.
joins
(
job
:
{
client
:
{
host
:
:users
}
})
.
where
(
users
:
{
id
:
current_user
.
id
})
end
@logs
=
@logs
.
where
(
'Time > ?'
,
days_ago
.
days
.
ago
)
.
order
(
Time
:
:desc
,
LogId
:
:desc
)
.
page
(
params
[
:page
]
)
end
private
def
require_logged_in
return
if
current_user
flash
[
:alert
]
=
'You need to log in first'
redirect_to
root_path
end
end
Event Timeline
Log In to Comment