diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile index 7ee4b14..4d9f0e5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' gem 'rails', '4.0.1' gem 'pg', '0.15.1' gem 'bcrypt-ruby', '3.1.2' +gem 'devise' #SCSS & Bootstrap gem 'bootstrap-sass', '2.3.2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 6635f55..a2adf61 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM arel (4.0.1) assert_difference (0.5.0) atomic (1.1.14) + bcrypt (3.1.7) bcrypt-ruby (3.1.2) better_errors (1.1.0) coderay (>= 1.0.0) @@ -51,6 +52,12 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) + devise (3.2.4) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) + warden (~> 1.2.3) diff-lcs (1.2.5) erubis (2.7.0) execjs (2.0.2) @@ -84,6 +91,7 @@ GEM multi_json (1.8.4) nokogiri (1.6.1) mini_portile (~> 0.5.0) + orm_adapter (0.5.0) pg (0.15.1) polyglot (0.3.3) pry (0.9.12.4) @@ -169,6 +177,8 @@ GEM uglifier (2.1.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + warden (1.2.3) + rack (>= 1.0) websocket (1.0.7) xpath (2.0.0) nokogiri (~> 1.3) @@ -182,6 +192,7 @@ DEPENDENCIES better_errors bootstrap-sass (= 2.3.2.0) capybara (= 2.1.0) + devise factory_girl factory_girl_rails (~> 4.0) growl (= 1.0.3) diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb index 40f2389..0a08ffc 100644 --- a/app/controllers/bikes_controller.rb +++ b/app/controllers/bikes_controller.rb @@ -1,5 +1,6 @@ class BikesController < ApplicationController before_action :set_bike, only: [:show, :edit, :update, :destroy] + before_action :authenticate_user! def index @bikes = Bike.all diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb index a2230d8..dd593fb 100644 --- a/app/controllers/volunteers_controller.rb +++ b/app/controllers/volunteers_controller.rb @@ -1,5 +1,6 @@ class VolunteersController < ApplicationController before_action :set_volunteer, only: [:show, :edit, :update, :destroy] + before_action :authenticate_user! def index @volunteers = Volunteer.all diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..c822027 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable +end diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..65ba288 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,12 @@ +
Welcome <%= @email %>!
+ +You can confirm your account email through the link below:
+ +<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..f667dc1 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +Hello <%= @resource.email %>!
+ +Someone has requested a link to change your password. You can do this through the link below.
+ +<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
+ +If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..41e148b --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +Hello <%= @resource.email %>!
+ +Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+ +Click the link below to unlock your account:
+ +<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5535098 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml new file mode 100644 index 0000000..dc06483 --- /dev/null +++ b/app/views/devise/registrations/new.html.haml @@ -0,0 +1,20 @@ +.container + %h2 Sign up + = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| + = devise_error_messages! + + = f.label :email + = f.email_field :email, autofocus: true + %br + + = f.label :password + = f.password_field :password, autocomplete: "off" + %br + + = f.label :password_confirmation + = f.password_field :password_confirmation, autocomplete: "off" + %br + + = f.submit "Sign up" + + = render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..f151ac1 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,17 @@ +<%= notice %>
+<%= alert %>
<%= yield %>