Skip to content
Browse files

hide navbar unless logged in, redirect to favorites on login

  • Loading branch information...
1 parent f494fac commit 7404dc95194b19a81340849fdf30ba33143f080f @blahed committed Nov 15, 2012
Showing with 28 additions and 28 deletions.
  1. +1 −1 app/controllers/sessions_controller.rb
  2. +26 −26 app/views/layouts/application.html.erb
  3. +1 −1 config/routes.rb
View
2 app/controllers/sessions_controller.rb
@@ -6,7 +6,7 @@ def create
user = User.where(:username => params[:username]).first
if user && user.authenticate(params[:password])
session[:user_id] = user.id
- redirect_to root_url, :notice => 'Logged in!'
+ redirect_to favorites_path, :notice => 'Logged in!'
else
flash.now.alert = 'Username or password is invalid'
render 'new'
View
52 app/views/layouts/application.html.erb
@@ -8,8 +8,8 @@
</head>
<body>
<div class="container">
- <div class="user-session">
- <% if current_user %>
+ <% if current_user %>
+ <div class="user-session">
logged in as <%= current_user.username %> &mdash;
<% if current_user.admin? %>
<span class='admin'>
@@ -18,31 +18,31 @@
</span>
<% end %>
<%= link_to 'logout', logout_path %>
- <% end %>
- </div>
- <div class="navbar">
- <div class="navbar-inner">
- <span class="brand">ROSWELL</span>
- <ul class="nav">
- <li <%= active_class_if(favorites_path) %> ><%= link_to 'Favorites', favorites_path %></li>
- <li class="dropdown<%= request.path =~ /\A\/accounts\// ? ' active' : '' %>">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">
- Accounts
- <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li><%= link_to 'Generic', accounts_generic_accounts_path %></li>
- <li><%= link_to 'Web', accounts_web_accounts_path %></li>
- </ul>
- </li>
- <li <%= active_class_if(software_licenses_path) %> ><%= link_to 'Licenses', software_licenses_path %></li>
- <li <%= active_class_if(notes_path) %> ><%= link_to 'Notes', notes_path %></li>
- </ul>
- <form class="navbar-search pull-right" action="<%= search_path %>">
- <input type="text" name="query" class="search-query" placeholder="Search">
- </form>
</div>
- </div>
+ <div class="navbar">
+ <div class="navbar-inner">
+ <span class="brand">ROSWELL</span>
+ <ul class="nav">
+ <li <%= active_class_if(favorites_path) %> ><%= link_to 'Favorites', favorites_path %></li>
+ <li class="dropdown<%= request.path =~ /\A\/accounts\// ? ' active' : '' %>">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+ Accounts
+ <b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu">
+ <li><%= link_to 'Generic', accounts_generic_accounts_path %></li>
+ <li><%= link_to 'Web', accounts_web_accounts_path %></li>
+ </ul>
+ </li>
+ <li <%= active_class_if(software_licenses_path) %> ><%= link_to 'Licenses', software_licenses_path %></li>
+ <li <%= active_class_if(notes_path) %> ><%= link_to 'Notes', notes_path %></li>
+ </ul>
+ <form class="navbar-search pull-right" action="<%= search_path %>">
+ <input type="text" name="query" class="search-query" placeholder="Search">
+ </form>
+ </div>
+ </div>
+ <% end %>
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
View
2 config/routes.rb
@@ -28,5 +28,5 @@
resources :groups, :except => [ :show ]
end
- root :to => 'accounts/web_accounts#index'
+ root :to => 'sessions#new'
end

0 comments on commit 7404dc9

Please sign in to comment.
Something went wrong with that request. Please try again.