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">
|
||||
<button type="submit">Create new vote</button>
|
||||
</form>
|
||||
|
||||
<form action="/logout" method="post">
|
||||
<button type="submit">Log out</button>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@
|
|||
<title>Title</title>
|
||||
</head>
|
||||
<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 %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
5
vote.rb
5
vote.rb
|
|
@ -84,6 +84,11 @@ post '/login' do
|
|||
end
|
||||
end
|
||||
|
||||
get '/logout' do
|
||||
session.clear
|
||||
redirect '/login'
|
||||
end
|
||||
|
||||
post '/logout' do
|
||||
session.clear
|
||||
redirect '/login'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue