summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-03 21:49:38 -0500
committerTomer Kimia <tkimia@purdue.edu>2014-03-03 21:49:38 -0500
commit661dbaf902d770dfbefa9ba1d9e4c28fc7abf891 (patch)
tree3fe6cba03179cc7d9f515a024b1fec31885ab823 /app
parentd5f15d40e0c0168bb430ebae39371590266d0eb5 (diff)
small things
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/scaffolds.css.scss1
-rw-r--r--app/controllers/sessions_controller.rb17
-rw-r--r--app/views/sessions/new.html.erb4
-rw-r--r--app/views/users/index.html.erb4
4 files changed, 16 insertions, 10 deletions
diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss
index dc22c99..f4c3040 100644
--- a/app/assets/stylesheets/scaffolds.css.scss
+++ b/app/assets/stylesheets/scaffolds.css.scss
@@ -29,7 +29,6 @@ a {
}
&:hover {
color: #000;
- font-weight:bold;
text-decoration: none;
}
}
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 68cb949..3417332 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,22 +1,25 @@
class SessionsController < ApplicationController
def new
+ if @user.nil?
+ @user = User.new
+ end
end
# find the user and create a new session
def create
- user = User.find_by(email: params[:session][:email].downcase)
- if user && user.authenticate(params[:session][:password])
- sign_in user
+ @user = User.find_by(email: params[:session][:email].downcase)
+ if @user && @user.authenticate(params[:session][:password])
+ sign_in @user
redirect_to root_path
else
- render 'new'
- end
+ redirect_to signin_path
+ end
end
def destroy
- sign_out
- redirect_to root_path
+ sign_out
+ redirect_to root_path
end
end
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index f942cf6..2e7a0d3 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,5 +1,7 @@
<h1>Sign in</h1>
-
+<% if @fail %>
+ <p class="error">Email and password combination not found</p>
+<% end %>
<div class="row">
<div class="span6 offset3">
<%= form_for(:session, url: sessions_path) do |f| %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index c128661..d92da4d 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -3,6 +3,7 @@
<table class="table table-hover">
<thead>
<tr>
+ <th>Username</th>
<th>Name</th>
<th>Pw hash</th>
<th></th>
@@ -14,7 +15,8 @@
<tbody>
<% @users.each do |user| %>
<tr>
- <td><%= link_to("#{user.name}", user, nil) %></td>
+ <td><%= link_to("#{user.user_name}", user, nil) %></td>
+ <td><%= user.name %></td>
<td> ******* </td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>