Skip to content

Commit

Permalink
Fixed default login view when logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
andreareginato committed Apr 21, 2011
1 parent 862ca35 commit 1a35f2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
20 changes: 10 additions & 10 deletions app/controllers/application_controller.rb
Expand Up @@ -33,16 +33,16 @@ def json?
request.format == "application/json"
end

def basic_auth
authenticate_or_request_with_http_basic do |username, password|
user = User.where(email: username).first
if user and user.verify(password)
@current_user = user
else
false
end
end
end
#def basic_auth
#authenticate_or_request_with_http_basic do |username, password|
#user = User.where(email: username).first
#if user and user.verify(password)
#@current_user = user
#else
#false
#end
#end
#end

def session_auth
session[:back] = request.url
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sessions_controller.rb
Expand Up @@ -9,9 +9,9 @@ def create
user = User.authenticate(params[:email], params[:password])
if user
session[:user_id] = user.id
#session[:back] ||= clients_path
#session[:back] ||= user_path(current_user)
#redirect_to session[:back], notice: "Logged in!"
redirect_to clients_path, :notice => "Logged in!"
redirect_to user, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
Expand Down
9 changes: 5 additions & 4 deletions app/views/layouts/application.html.erb
Expand Up @@ -32,12 +32,13 @@
<%= link_to "Log out", log_out_path %>
</div>
<div>
<% if current_user.admin? %>
<%= link_to("Users", users_path) %> |
<%= link_to("Scopes", scopes_path) %> |
<% end %>
<%= link_to("Home", current_user) %> |
<%= link_to("Accesses", accesses_path) %> |
<%= link_to("Clients", clients_path) %>
<% if current_user.admin? %> |
<%= link_to("Users", users_path) %> |
<%= link_to("Scopes", scopes_path) %>
<% end %>
</div>
<% else %>
<%= link_to "Sign up", sign_up_path %> or
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -29,7 +29,7 @@
put :unblock, on: :member
end

root :to => "users#new"
root :to => "sessions#new"

# sample resources
resources :pizzas, defaults: { format: "json" }
Expand Down

0 comments on commit 1a35f2a

Please sign in to comment.