diff options
| author | mo khan <mo@mokhan.ca> | 2014-05-21 22:32:45 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-05-21 22:32:45 -0600 |
| commit | 0e1f35bf3f1a023e3f71b916ec5927ab46800249 (patch) | |
| tree | 13deb602e0adff67bb4998f94eaa7c06f0cbfc78 | |
| parent | 1ea8b4a3094aed558448edd93704f7964521a15a (diff) | |
move passwords to my/passwords.
| -rw-r--r-- | app/controllers/my/passwords_controller.rb | 24 | ||||
| -rw-r--r-- | app/controllers/passwords_controller.rb | 24 | ||||
| -rw-r--r-- | app/views/my/passwords/index.html.erb (renamed from app/views/passwords/index.html.erb) | 2 | ||||
| -rw-r--r-- | app/views/shared/_account_nav.html.erb | 2 | ||||
| -rw-r--r-- | config/routes.rb | 7 | ||||
| -rw-r--r-- | spec/controllers/my/passwords_controller_spec.rb (renamed from spec/controllers/passwords_controller_spec.rb) | 2 |
6 files changed, 31 insertions, 30 deletions
diff --git a/app/controllers/my/passwords_controller.rb b/app/controllers/my/passwords_controller.rb new file mode 100644 index 00000000..7c0c8c0e --- /dev/null +++ b/app/controllers/my/passwords_controller.rb @@ -0,0 +1,24 @@ +module My + class PasswordsController < BaseController + def index + @user = current_user + end + + def update + ChangePassword.new(self).run(params[:user][:password], params[:user][:password_confirmation]) + end + + def password_changed(user) + @user = user + sign_in(@user, bypass: true) unless Rails.env.test? + flash[:notice] = t('passwords.updated') + render :index + end + + def password_changed_failed(user) + @user = user + flash[:error] = t(:passwords_do_not_match) + render :index + end + end +end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb deleted file mode 100644 index d081f1da..00000000 --- a/app/controllers/passwords_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -class PasswordsController < ApplicationController - before_filter :authenticate_user! - - def index - @user = current_user - end - - def update - ChangePassword.new(self).run(params[:user][:password], params[:user][:password_confirmation]) - end - - def password_changed(user) - @user = user - sign_in(@user, bypass: true) unless Rails.env.test? - flash[:notice] = t('passwords.updated') - render :index - end - - def password_changed_failed(user) - @user = user - flash[:error] = t(:passwords_do_not_match) - render :index - end -end diff --git a/app/views/passwords/index.html.erb b/app/views/my/passwords/index.html.erb index 3c38d2b2..f425b153 100644 --- a/app/views/passwords/index.html.erb +++ b/app/views/my/passwords/index.html.erb @@ -2,7 +2,7 @@ <div class="row"> <div class="span12"> - <%= form_for(@user, :url => pwd_path, :html => { :method => :patch, :class => "form-horizontal" }) do |f| %> + <%= form_for(@user, :url => my_password_path(@user), :html => { :method => :patch, :class => "form-horizontal" }) do |f| %> <div class="control-group"> <%= f.label :password, "New password", :class => "control-label" %> <div class="controls"> diff --git a/app/views/shared/_account_nav.html.erb b/app/views/shared/_account_nav.html.erb index 00574e82..e65fdf21 100644 --- a/app/views/shared/_account_nav.html.erb +++ b/app/views/shared/_account_nav.html.erb @@ -5,7 +5,7 @@ <li class="<%= selected == :creations ? "active" : "" %>"><%= link_to "Creations", my_cakes_path %></li> <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", my_favorites_path %></li> <li class="<%= selected == :basic_info ? "active" : "" %>"><%= link_to "Settings", my_settings_path %></li> - <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", pwd_path %></li> + <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", my_passwords_path %></li> <li class="<%= selected == :picture ? "active" : "" %>"><%= link_to "Picture", edit_avatar_path(current_user) %></li> <li class="pull-right"><%= link_to t('.logout'), destroy_user_session_path, class: "btn btn-inverse" %></li> <% if current_user.is_admin? %> diff --git a/config/routes.rb b/config/routes.rb index d2ef9566..0c415238 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,8 +44,6 @@ Cake::Application.routes.draw do get "/sitemap.xml", :to => "sitemap#index", :defaults => {:format => :xml} resources :avatars, :only => [:edit, :update] - get 'pwd' => "passwords#index" - patch 'pwd' => "passwords#update" root :to => "creations#index" @@ -69,6 +67,9 @@ Cake::Application.routes.draw do get 'dashboard', to: 'dashboard#index' resources :cakes, only: [:index] resources :favorites, only: [:index] - resources :settings, :only => [:index, :update] + resources :settings, only: [:index, :update] + resources :passwords, only: [:index, :update] + #get 'pwd' => "passwords#index" + #patch 'pwd' => "passwords#update" end end diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/my/passwords_controller_spec.rb index 5d688a7e..91ada670 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/my/passwords_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe PasswordsController do +describe My::PasswordsController do describe :update do context "when not logged in" do let(:user) { create(:user) } |
