Skip to content

Commit

Permalink
Merge pull request #121 from phiggins/member-logins-test
Browse files Browse the repository at this point in the history
Kenny Logins
  • Loading branch information
phiggins committed Jul 11, 2015
2 parents 865470d + 7e55acf commit f408db0
Show file tree
Hide file tree
Showing 32 changed files with 538 additions and 108 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0-p598
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ group :development, :test do
gem "minitest-rails", "~> 2.1.1"
gem "ZenTest", "~> 4.9"
gem "autotest-rails", "~> 4.2.1"
gem "letter_opener"
gem "pry"
end
52 changes: 30 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.7)
addressable (2.3.8)
arel (6.0.0)
autotest-rails (4.2.1)
ZenTest (~> 4.5)
bcrypt (3.1.10)
buftok (0.2.0)
builder (3.2.2)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1)
coffee-script-source (1.9.1.1)
devise (3.4.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -60,56 +61,63 @@ GEM
warden (~> 1.2.3)
equalizer (0.0.11)
erubis (2.7.0)
execjs (2.4.0)
execjs (2.5.2)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
font-awesome-rails (4.3.0.0)
railties (>= 3.2, < 5.0)
globalid (0.3.3)
globalid (0.3.5)
activesupport (>= 4.1.0)
haml (4.0.6)
tilt
hike (1.2.3)
http (0.6.3)
http (0.6.4)
http_parser.rb (~> 0.6.0)
http_parser.rb (0.6.0)
httparty (0.13.3)
httparty (0.13.5)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.3)
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
json (1.8.2)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.3)
loofah (2.0.1)
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
mime-types (2.4.3)
method_source (0.8.2)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.5.1)
minitest (5.6.1)
minitest-rails (2.1.1)
minitest (~> 5.4)
railties (~> 4.1)
multi_json (1.11.0)
multi_xml (0.5.5)
multipart-post (2.0.0)
naught (1.0.0)
nested_form (0.3.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
pg (0.18.1)
rack (1.6.0)
pg (0.18.2)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.1)
rack-pjax (0.8.0)
nokogiri (~> 1.5)
rack (~> 1.1)
Expand Down Expand Up @@ -159,20 +167,18 @@ GEM
responders (2.1.0)
railties (>= 4.2.0, < 5)
safe_yaml (1.0.4)
sass (3.4.13)
sass-rails (5.0.1)
sass (3.4.14)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
simple_oauth (0.3.1)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
slop (3.6.0)
sprockets (3.1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
sprockets-rails (2.3.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
Expand Down Expand Up @@ -212,8 +218,10 @@ DEPENDENCIES
devise (~> 3.4.1)
httparty (~> 0.13.3)
jquery-rails (~> 4.0.3)
letter_opener
minitest-rails (~> 2.1.1)
pg (~> 0.18.1)
pry
rails (~> 4.2.1)
rails_admin (~> 0.6.7)
rake (~> 10.4.2)
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/seattlerb.css
Original file line number Diff line number Diff line change
Expand Up @@ -3680,6 +3680,10 @@ input[type="submit"].btn {
margin-bottom: 18px;
list-style: none; }

.profile_nav {
list-style: inline;
}

/* line 16, /Users/mike/Projects/oss/seattlerb-style.org/vendor/assets/stylesheets/twitter/bootstrap/_navs.scss */
.nav > li > a {
display: block; }
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?

# filter_parameter_logging :password
helper :all
protect_from_forgery

protected

def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up).push(:username, :name, :email, :twitter, :github, :ruby_gems_id, :website, :bio)
end
end
65 changes: 65 additions & 0 deletions app/controllers/members/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class Members::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]
before_filter :spam_trap, only: :create

def spam_trap
redirect_to members_url and return if sign_up_params[:username].present?
end

# GET /resource/sign_up
# def new
# super
# end

# POST /resource
# def create
# super
# end

# GET /resource/edit
# def edit
# super
# end

# PUT /resource
# def update
# super
# end

# DELETE /resource
# def destroy
# super
# end

# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end

# protected

# You can put the params you want to permit in the empty array.
# def configure_sign_up_params
# devise_parameter_sanitizer.for(:sign_up) << :attribute
# end

# You can put the params you want to permit in the empty array.
# def configure_account_update_params
# devise_parameter_sanitizer.for(:account_update) << :attribute
# end

# The path used after sign up.
def after_sign_up_path_for(resource)
members_path
end

# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
29 changes: 14 additions & 15 deletions app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ def index
@title = "Members"
end

def new
@member = Member.new
def edit
@member = Member.find params[:id]
end

def create
#spam catch to redirect - maybe the bots were ignoring the spam field
redirect_to members_url and return if member_params[:username].present?
@member = Member.new(member_params)

respond_to do |format|
if @member.save
format.html { redirect_to members_path, notice: 'Thank you for submitting, we will validate your request.' }
else
format.html { render action: "new" }
end
def update
@member = current_member
if @member.update(member_params)
redirect_to member_path, notice: 'Updated successfully'
else
render action: "edit"
end
end

def show
@member = Member.find params[:id]
end

private

def member_params
params.require(:member).permit(:name, :email, :twitter, :github, :ruby_gems_id, :website, :bio, :username)
params.require(:member).permit(:name, :email, :twitter, :github, :ruby_gems_id, :website, :bio)
end
end
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def twitter_link person
icon_link "icon-leaf", "@#{v}", v, "http://twitter.com/"
end

def nav_item_link link_label, link_path
content_tag :li, link_to(link_label, link_path), :class => ('active' if current_page?(link_path))
def nav_item_link link_label, link_path, method=nil
content_tag :li, link_to(link_label, link_path, method), :class => ('active' if current_page?(link_path))
end

def title_or_action
Expand Down
4 changes: 4 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
class Member < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
NONE = "missing_image.png"

attr_accessor :username # fake attribute for spam trapping
Expand Down
8 changes: 8 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
<%= nav_item_link "Talks", talks_path %>
<%= nav_item_link "Blog", posts_path %>
</ul>
<ul class="nav profile_nav pull-right">
<% if signed_in? %>
<%= nav_item_link current_member.name, member_path(current_member) %>
<%= nav_item_link "Log out", destroy_member_session_path, method: :delete %>
<% else %>
<%= nav_item_link "Log in", new_member_session_path %>
<% end %>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
Expand Down
12 changes: 3 additions & 9 deletions app/views/members/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.text_field :name, autofocus: true %>
</div>
<div class="field">
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.email_field :email %>
</div>
<div class="field">
<%= f.label :twitter, 'Twitter handle' %>
Expand All @@ -39,12 +38,7 @@
<%= f.text_area :bio %>
</div>

<p style="width: 1px; height: 1px; overflow: hidden;">
Please leave following field blank:
<%= f.text_area :username %>
</p>

<div class="actions">
<%= f.submit 'Submit', :class => "btn" %>
</div>
<% end %>
<% end %>
5 changes: 5 additions & 0 deletions app/views/members/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Edit Your Profile</h1>

<%= render 'form' %>
<%= link_to 'Back', member_path %>
2 changes: 1 addition & 1 deletion app/views/members/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= link_to 'Become a Seattle.rb member!', new_member_path, {:id => 'new_member_button'} %>
<%= link_to 'Become a Seattle.rb member!', new_member_registration_path, {:id => 'new_member_button'} %>
</br></br></br>
<% @members.each do |member| %>
<div class='featured profile row'>
Expand Down
8 changes: 8 additions & 0 deletions app/views/members/mailer/reset_password_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
22 changes: 22 additions & 0 deletions app/views/members/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h2>Change your password</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>

<div class="field">
<%= f.label :password, "New password" %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>

<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>

<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "members/shared/links" %>
Loading

0 comments on commit f408db0

Please sign in to comment.