Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F665088
page_controller.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
page_controller.ex
View Options
defmodule
NolaWeb.PageController
do
use
NolaWeb
,
:controller
plug
NolaWeb.ContextPlug
when
action
not
in
[
:token
]
plug
NolaWeb.ContextPlug
,
[
restrict
:
:public
]
when
action
in
[
:token
]
def
token
(
conn
,
%{
"token"
=>
token
})
do
with
\
{
:ok
,
account
,
perks
}
<-
Nola.AuthToken
.
lookup
(
token
)
do
IO
.
puts
(
"Authenticated account
#{
inspect
account
}
"
)
conn
=
put_session
(
conn
,
:account
,
account
)
case
perks
do
nil
->
redirect
(
conn
,
to
:
"/"
)
{
:redirect
,
path
}
->
redirect
(
conn
,
to
:
path
)
{
:external_redirect
,
url
}
->
redirect
(
conn
,
external
:
url
)
end
else
z
->
IO
.
inspect
(
z
)
text
(
conn
,
"Error: invalid or expired token"
)
end
end
def
index
(
conn
=
%{
assigns
:
%{
account
:
account
}},
_
)
do
memberships
=
Nola.Membership
.
of_account
(
account
)
users
=
Nola.UserTrack
.
find_by_account
(
account
)
metas
=
Nola.Account
.
get_all_meta
(
account
)
predicates
=
Nola.Account
.
get_predicates
(
account
)
conn
|>
assign
(
:title
,
account
.
name
)
|>
render
(
"user.html"
,
users
:
users
,
memberships
:
memberships
,
metas
:
metas
,
predicates
:
predicates
)
end
def
irc
(
conn
,
_
)
do
bot_helps
=
for
mod
<-
Nola.IRC
.
env
(
:handlers
)
do
mod
.
irc_doc
()
end
render
conn
,
"irc.html"
,
bot_helps
:
bot_helps
end
def
authenticate
(
conn
,
_
)
do
with
\
{
:account
,
account_id
}
when
is_binary
(
account_id
)
<-
{
:account
,
get_session
(
conn
,
:account
)},
{
:account
,
account
}
when
not
is_nil
(
account
)
<-
{
:account
,
Nola.Account
.
get
(
account_id
)}
do
assign
(
conn
,
:account
,
account
)
else
_
->
conn
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Fri, Feb 27, 9:15 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
87158
Default Alt Text
page_controller.ex (1 KB)
Attached To
rNOLA Nola
Event Timeline
Log In to Comment