Commit 0e1f35bf
Changed files (6)
app
controllers
views
my
passwords
shared
config
spec
controllers
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
app/controllers/passwords_controller.rb
@@ -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
app/views/passwords/index.html.erb → 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">
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
spec/controllers/passwords_controller_spec.rb → 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) }