| @@ -1 +1,9 @@ | |||||
| . | |||||
| Before installing/deploying: | |||||
| $ export APOLLO_HOSTNAME=example.org | |||||
| On Heroku: | |||||
| $ heroku config:add APOLLO_HOSTNAME=example.org | |||||
| Replace `example.org` with your own hostname. When running locally this will probably be `localhost:3000`. | |||||
| @@ -32,7 +32,18 @@ div { | |||||
| } } | } } | ||||
| #notice { | #notice { | ||||
| color: green; } | |||||
| background-color: green; | |||||
| color: white; | |||||
| padding: 5px 10px; | |||||
| font-size: 1.2rem; | |||||
| } | |||||
| #alert { | |||||
| background-color: red; | |||||
| color: white; | |||||
| padding: 5px 10px; | |||||
| font-size: 1.2rem; | |||||
| } | |||||
| .field_with_errors { | .field_with_errors { | ||||
| padding: 2px; | padding: 2px; | ||||
| @@ -132,3 +143,7 @@ h2 { | |||||
| font-size: 1.0rem; | font-size: 1.0rem; | ||||
| border-radius: 10px; | border-radius: 10px; | ||||
| } | } | ||||
| #userbar { | |||||
| background-color: #eee; | |||||
| } | |||||
| @@ -1,8 +1,16 @@ | |||||
| class PasswordResetsController < ApplicationController | class PasswordResetsController < ApplicationController | ||||
| # before_filter :require_no_user | |||||
| def create | def create | ||||
| @user = User.find_by_email(params[:email]) | @user = User.find_by_email(params[:email]) | ||||
| @user.deliver_reset_password_instructions! if @user | |||||
| redirect_to(root_path, :notice => "Instructions have been sent to your email.") | |||||
| if @user | |||||
| unless @user.deliver_reset_password_instructions! | |||||
| redirect_to(root_path, :notice => "Please wait a while before requesting another password reset.") | |||||
| return | |||||
| end | |||||
| end | |||||
| redirect_to(new_password_reset_path, :notice => "Instructions have been sent to your email.") | |||||
| end | end | ||||
| def edit | def edit | ||||
| @@ -12,14 +12,14 @@ class UsersController < ApplicationController | |||||
| # GET /users/1 | # GET /users/1 | ||||
| # GET /users/1.json | # GET /users/1.json | ||||
| def show | |||||
| @user = User.find(params[:id]) | |||||
| respond_to do |format| | |||||
| format.html # show.html.erb | |||||
| format.json { render json: @user } | |||||
| end | |||||
| end | |||||
| # def show | |||||
| # @user = User.find(params[:id]) | |||||
| # | |||||
| # respond_to do |format| | |||||
| # format.html # show.html.erb | |||||
| # format.json { render json: @user } | |||||
| # end | |||||
| # end | |||||
| # GET /users/new | # GET /users/new | ||||
| # GET /users/new.json | # GET /users/new.json | ||||
| @@ -44,7 +44,7 @@ class UsersController < ApplicationController | |||||
| respond_to do |format| | respond_to do |format| | ||||
| if @user.save | if @user.save | ||||
| format.html { redirect_to @user, notice: 'User was successfully created.' } | |||||
| format.html { redirect_to users_path, notice: 'User was successfully created.' } | |||||
| format.json { render json: @user, status: :created, location: @user } | format.json { render json: @user, status: :created, location: @user } | ||||
| else | else | ||||
| format.html { render action: "new" } | format.html { render action: "new" } | ||||
| @@ -71,13 +71,13 @@ class UsersController < ApplicationController | |||||
| # DELETE /users/1 | # DELETE /users/1 | ||||
| # DELETE /users/1.json | # DELETE /users/1.json | ||||
| def destroy | |||||
| @user = User.find(params[:id]) | |||||
| @user.destroy | |||||
| respond_to do |format| | |||||
| format.html { redirect_to users_url } | |||||
| format.json { head :no_content } | |||||
| end | |||||
| end | |||||
| # def destroy | |||||
| # @user = User.find(params[:id]) | |||||
| # @user.destroy | |||||
| # | |||||
| # respond_to do |format| | |||||
| # format.html { redirect_to users_url } | |||||
| # format.json { head :no_content } | |||||
| # end | |||||
| # end | |||||
| end | end | ||||
| @@ -8,7 +8,7 @@ class UserMailer < ActionMailer::Base | |||||
| # | # | ||||
| def reset_password_email(user) | def reset_password_email(user) | ||||
| @user = user | @user = user | ||||
| @url = "http://localhost:3000/password_resets/#{user.reset_password_token}/edit" | |||||
| @url = edit_password_reset_url(user.reset_password_token) | |||||
| mail(:to => user.email, :subject => "Your password has been reset") | mail(:to => user.email, :subject => "Your password has been reset") | ||||
| end | end | ||||
| end | end | ||||
| @@ -4,6 +4,7 @@ class User | |||||
| key :email, String | key :email, String | ||||
| key :crypted_password, String | key :crypted_password, String | ||||
| key :salt, String | key :salt, String | ||||
| timestamps! | |||||
| authenticates_with_sorcery! | authenticates_with_sorcery! | ||||
| # attr_accessible :email, :password, :password_confirmation | # attr_accessible :email, :password, :password_confirmation | ||||
| @@ -8,6 +8,12 @@ | |||||
| %body | %body | ||||
| - if notice | |||||
| %p#notice= notice | |||||
| - if alert | |||||
| %p#alert= alert | |||||
| = link_to(image_tag("TAL_logo_blue-h100.png", :size => "275x100", :alt => "Talk About Local logo"), :root, :class => "logo") | = link_to(image_tag("TAL_logo_blue-h100.png", :size => "275x100", :alt => "Talk About Local logo"), :root, :class => "logo") | ||||
| #userbar | #userbar | ||||
| @@ -16,9 +22,8 @@ | |||||
| = current_user.email | = current_user.email | ||||
| = link_to "Log out", logout_path | = link_to "Log out", logout_path | ||||
| - else | - else | ||||
| = link_to "Log in", login_path | |||||
| %p#notice= notice | |||||
| -# | |||||
| = link_to "Log in", login_path | |||||
| = yield | = yield | ||||
| @@ -0,0 +1,11 @@ | |||||
| %h1 Reset your password | |||||
| %p Type your email address here and we'll send you a link to a page where you can choose a new password. | |||||
| = form_tag password_resets_path, :method => :post do | |||||
| .field | |||||
| = label_tag :email | |||||
| %br | |||||
| = text_field_tag :email | |||||
| = submit_tag "Reset my password" | |||||
| @@ -18,6 +18,4 @@ | |||||
| .actions | .actions | ||||
| = submit_tag "Log in" | = submit_tag "Log in" | ||||
| %h1 Forgotten your password? | |||||
| = render "forgot_password_form" | |||||
| = link_to "Forgotten your password?", new_password_reset_path | |||||
| @@ -1,4 +1,5 @@ | |||||
| Hello, | Hello, | ||||
| = @user.email | = @user.email | ||||
| You have requested to reset your password. | You have requested to reset your password. | ||||
| @@ -8,12 +8,15 @@ | |||||
| .field | .field | ||||
| = f.label :email | = f.label :email | ||||
| %br | |||||
| = f.text_field :email | = f.text_field :email | ||||
| .field | .field | ||||
| = f.label :password | = f.label :password | ||||
| %br | |||||
| = f.password_field :password | = f.password_field :password | ||||
| .field | .field | ||||
| = f.label :password_confirmation | = f.label :password_confirmation | ||||
| %br | |||||
| = f.password_field :password_confirmation | = f.password_field :password_confirmation | ||||
| .actions | .actions | ||||
| = f.submit 'Save' | = f.submit 'Save' | ||||
| @@ -1,23 +1,15 @@ | |||||
| %h1 Listing users | |||||
| %h1 Users | |||||
| = link_to 'New User', new_user_path, :class => 'button' | |||||
| %table | %table | ||||
| %tr | %tr | ||||
| %th Email | %th Email | ||||
| %th Crypted password | |||||
| %th Salt | |||||
| %th | |||||
| %th | |||||
| %th | |||||
| %th Joined | |||||
| - @users.each do |user| | - @users.each do |user| | ||||
| %tr | %tr | ||||
| %td= user.email | |||||
| %td= user.crypted_password | |||||
| %td= user.salt | |||||
| %td= link_to 'Show', user | |||||
| %td= link_to 'Edit', edit_user_path(user) | |||||
| %td= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete | |||||
| %br | |||||
| = link_to 'New User', new_user_path | |||||
| %td= link_to user.email, "mailto:#{user.email}" | |||||
| %td | |||||
| = time_ago_in_words(user.created_at) | |||||
| ago | |||||
| @@ -15,8 +15,11 @@ if defined?(Bundler) | |||||
| # Bundler.require(:default, :assets, Rails.env) | # Bundler.require(:default, :assets, Rails.env) | ||||
| end | end | ||||
| module Apollo | module Apollo | ||||
| class Application < Rails::Application | class Application < Rails::Application | ||||
| config.action_mailer.default_url_options = { :host => ENV['APOLLO_HOSTNAME'] } | |||||
| # Settings in config/environments/* take precedence over those specified here. | # Settings in config/environments/* take precedence over those specified here. | ||||
| # Application configuration should go into files in config/initializers | # Application configuration should go into files in config/initializers | ||||
| # -- all .rb files in that directory are automatically loaded. | # -- all .rb files in that directory are automatically loaded. | ||||
| @@ -303,7 +303,7 @@ Rails.application.config.sorcery.configure do |config| | |||||
| # hammering protection, how long to wait before allowing another email to be sent. | # hammering protection, how long to wait before allowing another email to be sent. | ||||
| # Default: `5 * 60` | # Default: `5 * 60` | ||||
| # | # | ||||
| # user.reset_password_time_between_emails = | |||||
| user.reset_password_time_between_emails = 1 * 60 | |||||
| # -- brute_force_protection -- | # -- brute_force_protection -- | ||||