diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/sessions_controller.rb | 9 | ||||
-rw-r--r-- | app/views/sessions/new.html.erb | 25 |
2 files changed, 14 insertions, 20 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f857f27..4bd69a5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -11,13 +11,8 @@ class SessionsController < ApplicationController # POST /sessions.json def create # find the user... - - @user = User.find_by(email: params[:session][:email]) - - if @user.nil? - @user = User.find_by_user_name(params[:session][:user_name]) - end - + #find by email + @user = User.find_by_email(params[:session][:username_or_email]) || User.find_by_user_name(params[:session][:username_or_email]) #@session = Session.new(@user) # ... and create a new session respond_to do |format| diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 6d73b1f..2b40ed9 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,23 +1,22 @@ <h1>Sign in</h1> <% if @user.nil? %> - <p class="errors"> The email or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email and password. </p> + <p class="errors"> The email/username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email/username and password. </p> <% end %> -<div class="row"> + <div class="span6 offset3"> <%= form_for(:session, url: sessions_path) do |f| %> - - <%= f.label :email %> - <%= f.text_field :email%> - - <%= f.label :user_name %> - <%= f.text_field :user_name%> - - <%= f.label :password %> + <p> + <%= f.label(:username_or_email, "Username/Email") %><br/> + <%= f.text_field :username_or_email%> + </p> + <p> + <%= f.label :password %><br/> <%= f.password_field :password %> - + </p> + <p> <%= f.submit "Sign in", class: "btn btn-large btn-primary" %> + </p> <% end %> - <p>New user? <%= link_to "Sign up now!", new_user_path %></p> + <p>New user? <%= link_to("Sign up now!", new_user_path) %></p> </div> -</div> |