diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-03-04 17:59:16 -0500 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-03-04 17:59:16 -0500 |
commit | 728f874deaf6ceb097d1a5f5cdf7e58a04cec557 (patch) | |
tree | 6bd1f665e51d73230bde088f044f122e332d58e9 | |
parent | 8740f17405abef0f4975f028e33b3029fcb35634 (diff) | |
parent | e587dc3fab34724d06eceb042c6e9eed6a7d95f4 (diff) |
Merge branch 'master' of http://github.com/LukeShu/leaguer
-rw-r--r-- | app/controllers/sessions_controller.rb | 19 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 2 | ||||
-rw-r--r-- | app/views/sessions/new.html.erb | 4 | ||||
-rw-r--r-- | config/routes.rb | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index fa5d024..a74cbd3 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,9 +2,7 @@ class SessionsController < ApplicationController # GET /sessions/new def new - if @user.nil? - @user = User.new - end + @user = User.new end # POST /sessions @@ -12,12 +10,15 @@ class SessionsController < ApplicationController # find the user... @user = User.find_by(email: params[:session][:email].downcase) # ... and create a new session - if @user && @user.authenticate(params[:session][:password]) - sign_in @user - redirect_to root_path - else - redirect_to new_session_path - end + respond_to do |format| + if @user && @user.authenticate(params[:session][:password]) + sign_in @user + redirect_to root_path + else + format.html { render action: 'new' } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end end # DELETE /sessions/current diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e13a8df..9cc30bc 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -20,7 +20,7 @@ <div id="log-buttons"> <% if signed_in? %> <%= current_user.user_name.upcase %> - <%= link_to "Sign out", session_path("/signout"), method: "delete", :class => "signout", :role => "button" %> + <%= link_to "Sign out", "/signout", method: "delete", :class => "signout", :role => "button" %> <% else %> <%= link_to "Log in", new_session_path, :class => "signin", :role => "button" %> <%= link_to "Sign up", new_user_path, :class => "signup", :role => "button" diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index a820b2f..550a54d 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,6 +1,6 @@ <h1>Sign in</h1> -<% if @fail %> - <p class="error">Email and password combination not found</p> +<% if @user.nil? %> + <p class="errors"> The username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current username and password. </p> <% end %> <div class="row"> <div class="span6 offset3"> diff --git a/config/routes.rb b/config/routes.rb index 90abea4..522b39f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Leaguer::Application.routes.draw do #creates sessions as a resource but limits it to these actions match '/signup', to: 'users#new', via: 'get' match '/signin', to: 'sessions#new', via: 'get' - match '/signout', to: 'sessions#destroy', via: 'get' + match '/signout', to: 'sessions#destroy', via: 'delete' resources :users |