Display login widget on all pages
This commit is contained in:
parent
3783b5ffd0
commit
6d6264181e
3 changed files with 10 additions and 4 deletions
|
|
@ -15,7 +15,3 @@
|
||||||
<form action="/votes/new" method="get">
|
<form action="/votes/new" method="get">
|
||||||
<button type="submit">Create new vote</button>
|
<button type="submit">Create new vote</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="/logout" method="post">
|
|
||||||
<button type="submit">Log out</button>
|
|
||||||
</form>
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@
|
||||||
<title>Title</title>
|
<title>Title</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<% if current_user %>
|
||||||
|
<p>Logged in as <%= current_user.email %>. <a href="/logout">Logout</a></p>
|
||||||
|
<% else %>
|
||||||
|
<p><a href="/login">Login</a></p>
|
||||||
|
<% end %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
5
vote.rb
5
vote.rb
|
|
@ -84,6 +84,11 @@ post '/login' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/logout' do
|
||||||
|
session.clear
|
||||||
|
redirect '/login'
|
||||||
|
end
|
||||||
|
|
||||||
post '/logout' do
|
post '/logout' do
|
||||||
session.clear
|
session.clear
|
||||||
redirect '/login'
|
redirect '/login'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue