Skip to content

Commit

Permalink
hide navbar unless logged in, redirect to favorites on login
Browse files Browse the repository at this point in the history
  • Loading branch information
blahed committed Nov 15, 2012
1 parent f494fac commit 7404dc9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
52 changes: 26 additions & 26 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand All @@ -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) %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.