Skip to content

Commit

Permalink
fixed signup email duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
guub committed Nov 25, 2016
1 parent 63b28cc commit 1af6a26
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AdminController < ApplicationController

http_basic_authenticate_with name: "jungle", password: "boogie"
http_basic_authenticate_with name: ENV['ADMIN_NAME'], password: ENV['ADMIN_PASSWORD']

end
21 changes: 21 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class SessionsController < ApplicationController

def new
end

def create
if user = User.authenticate_with_credentials(params[:email], params[:password])
session[:user_id] = user.id
redirect_to '/'
else
flash[:notice] = "Incorrect email or password."
redirect_to '/login'
end
end

def destroy
session[:user_id] = nil
redirect_to '/'
end

end
2 changes: 2 additions & 0 deletions app/helpers/appication_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationController
end
2 changes: 0 additions & 2 deletions app/helpers/application_helper.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout 'mailer'
end
9 changes: 9 additions & 0 deletions app/mailers/order_mailers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class OrderMailer < ApplicationMailer
default from: 'no-reply@jungle.com'

def receipt_email(order)
@order = order
@products = Product.joins(:line_items).where('line_items.order_id' => order.id).select('products.name, line_items.quantity, line_items.item_price_cents, line_items.total_price_cents')
mail(to: @order.email, subject: "Jungle Receipt for order ##{@order.id}")
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class User < ActiveRecord::Base

validates :first_name, presence: true
validates :last_name, presence: true
validates :email, presence: true
validates :email, presence: true, uniqueness: true;
validates :password_digest, presence: true

has_secure_password
Expand Down
14 changes: 14 additions & 0 deletions app/views/order_mailer/receipt_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Thank you for your order</h1>
<p>You ordered:</p>
<% @products.each do |product| %>
<p><%=product.quantity%> <%=product.name%> for $<%=product.item_price_cents/100.00%></p>
<% end %>
<p>Total: $<%= (@order.total_cents/100.00).round(2) %></p>
</body>
</html>
1 change: 1 addition & 0 deletions app/views/orders/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<%= @cart_total %>
</th>
</tr>
<div> To @order.email </div>
</tfoot>
</table>
</div>
Expand Down
2 changes: 0 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,13 @@ def open_asset(file_name)
})

User.create!({
id: 1,
first_name: "Guy",
last_name: "Booth",
email: "guy@guy",
password_digest: "No Bueno"
})

User.create!({
id: 2,
first_name: "Benno",
last_name: "Booth",
email: "ben@ben",
Expand Down
22 changes: 22 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
0 info it worked if it ends with ok
1 verbose cli [ '/home/vagrant/.nvm/versions/node/v6.7.0/bin/node',
1 verbose cli '/home/vagrant/.nvm/versions/node/v6.7.0/bin/npm',
1 verbose cli 'start' ]
2 info using npm@3.10.3
3 info using node@v6.7.0
4 verbose stack Error: ENOENT: no such file or directory, open '/vagrant/package.json'
4 verbose stack at Error (native)
5 verbose cwd /vagrant/jungle
6 error Linux 4.4.0-21-generic
7 error argv "/home/vagrant/.nvm/versions/node/v6.7.0/bin/node" "/home/vagrant/.nvm/versions/node/v6.7.0/bin/npm" "start"
8 error node v6.7.0
9 error npm v3.10.3
10 error path /vagrant/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/vagrant/package.json'
15 error enoent ENOENT: no such file or directory, open '/vagrant/package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

0 comments on commit 1af6a26

Please sign in to comment.