push_type_auth 0.1.0.beta3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/push_type/profiles_controller.rb +50 -0
- data/app/views/push_type/profiles/edit.html.haml +46 -0
- data/config/routes.rb +2 -0
- data/lib/push_type/auth/engine.rb +0 -1
- data/lib/tasks/push_type_tasks.rake +26 -4
- data/test/controllers/concerns/push_type/authentication_methods_test.rb +15 -0
- data/test/controllers/concerns/push_type/invitation_methods_test.rb +11 -0
- data/test/controllers/push_type/profiles_controller_test.rb +33 -0
- data/test/controllers/push_type/users_controller_test.rb +24 -0
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/migrate/{20141205213533_create_push_type_users.push_type.rb → 20150102204443_create_push_type_users.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20141205213534_create_push_type_nodes.push_type.rb → 20150102204444_create_push_type_nodes.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20141205213535_create_push_type_node_hierarchies.push_type.rb → 20150102204445_create_push_type_node_hierarchies.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20141205213536_create_push_type_assets.push_type.rb → 20150102204446_create_push_type_assets.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20141205213537_devise_extend_push_type_users.push_type_auth.rb → 20150102204447_devise_extend_push_type_users.push_type_auth.rb} +0 -0
- data/test/dummy/db/schema.rb +1 -1
- data/test/dummy/log/test.log +696 -269
- data/test/dummy/tmp/cache/assets/test/sass/806626419a476c98acb0fcf38feea6623fb99ce0/admin.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/806626419a476c98acb0fcf38feea6623fb99ce0/foundation_and_overrides.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/12375f1bf3d91db0a06c3fc436918949 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b3b2a83d3d7d735130f0b029e58b29b8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/dd803fd7a93619599c7e703c2b307411 +0 -0
- data/test/factories.rb +7 -0
- data/test/models/concerns/push_type/authenticatable_test.rb +52 -0
- metadata +46 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd94702289922c6faf9dbfb00b87173b17362142
|
4
|
+
data.tar.gz: 4f1229a7a6b70251af11675f5991651f49775502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f4c5f59e517df9648ac03ff8d13a7e9c0d80a3fdb4b8ac2c20ba5ea18f077c91efa9fbd5b155a9712fa80812f338acf3086aae21836f4fd76654e1f2c4098d
|
7
|
+
data.tar.gz: 64d4908776dc990a7d76d6844f0ab9953992a926310b5dfe1dc3d8bce2ecdd9e89fc6c7c3463db1ab24f8e1e3c0556d507d14428879ff351eca50bb848a3440f
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_dependency "push_type/admin_controller"
|
2
|
+
|
3
|
+
module PushType
|
4
|
+
class ProfilesController < AdminController
|
5
|
+
|
6
|
+
before_filter :load_user
|
7
|
+
|
8
|
+
def edit
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
if update_user profile_params
|
13
|
+
flash[:notice] = 'Profile successfully updated.'
|
14
|
+
sign_in @user, bypass: true
|
15
|
+
redirect_to push_type.edit_profile_path
|
16
|
+
else
|
17
|
+
render 'edit'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def initial_breadcrumb
|
24
|
+
breadcrumbs.add 'Profile', push_type.edit_profile_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_user
|
28
|
+
@user = current_user
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_user(user_params)
|
32
|
+
if password_required?
|
33
|
+
@user.update_with_password user_params
|
34
|
+
else
|
35
|
+
user_params.delete :current_password
|
36
|
+
@user.update_without_password user_params
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def password_required?
|
41
|
+
profile_params[:password].present? || profile_params[:password_confirmation].present?
|
42
|
+
end
|
43
|
+
|
44
|
+
def profile_params
|
45
|
+
fields = [:name, :email, :current_password, :password, :password_confirmation] + @user.fields.keys
|
46
|
+
params.fetch(:user, {}).permit(*fields)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
- title 'Profile'
|
2
|
+
|
3
|
+
.medium-4.columns
|
4
|
+
.side-panel{ :'side-panel' => true }
|
5
|
+
%ul.side-nav
|
6
|
+
%li.heading Settings
|
7
|
+
%li= link_to 'Profile', push_type.edit_profile_path
|
8
|
+
|
9
|
+
|
10
|
+
.medium-8.columns
|
11
|
+
= form_for @user, url: push_type.profile_path do |f|
|
12
|
+
.container
|
13
|
+
.head
|
14
|
+
.title= yield :title
|
15
|
+
.body.padded
|
16
|
+
.row.title
|
17
|
+
.columns
|
18
|
+
= f.label :name
|
19
|
+
= f.text_field :name
|
20
|
+
.row.email
|
21
|
+
.columns
|
22
|
+
= f.label :email
|
23
|
+
= f.email_field :email
|
24
|
+
|
25
|
+
%div{ ng: { init: "showPasswordFields=#{ !@user.errors.select { |a, e| !e.empty? }.empty? }" } }
|
26
|
+
.row{ ng: { hide: 'showPasswordFields' } }
|
27
|
+
.columns
|
28
|
+
%a.button.secondary.tiny.radius{ ng: { click: 'showPasswordFields=true' } }= ficon :lock, 'Change password'
|
29
|
+
.row.password{ ng: { show: 'showPasswordFields' } }
|
30
|
+
.small-4.columns
|
31
|
+
= f.label :current_password
|
32
|
+
= f.password_field :current_password
|
33
|
+
.small-4.columns
|
34
|
+
= f.label :password, 'New password'
|
35
|
+
= f.password_field :password
|
36
|
+
.small-4.columns
|
37
|
+
= f.label :password_confirmation, 'Confirm new password'
|
38
|
+
= f.password_field :password_confirmation
|
39
|
+
|
40
|
+
.row.custom-fields
|
41
|
+
- @user.fields.each do |key, field|
|
42
|
+
= render_custom_field field, f
|
43
|
+
|
44
|
+
.row.submit.text-center
|
45
|
+
%button.button.radius= ficon :check, 'Update profile'
|
46
|
+
|
data/config/routes.rb
CHANGED
@@ -15,7 +15,6 @@ module PushType
|
|
15
15
|
PushType::AdminController.send :include, PushType::AuthenticationMethods
|
16
16
|
PushType::UsersController.send :include, PushType::InvitationMethods
|
17
17
|
DeviseController.helper PushType::AdminHelper
|
18
|
-
DeviseController.helper PushType::AuthHelper
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -1,4 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
namespace :push_type do
|
4
|
+
desc 'Create confirmed and authenticated user account'
|
5
|
+
task create_user: :environment do
|
6
|
+
say 'Creating user. Please answer questions...'
|
7
|
+
|
8
|
+
user = PushType::User.new({
|
9
|
+
name: ask("Full name:\t"),
|
10
|
+
email: ask("Email address:\t"),
|
11
|
+
password: ask("Password:\t") { |q| q.echo = '*' },
|
12
|
+
|
13
|
+
confirmation_sent_at: Time.zone.now,
|
14
|
+
confirmed_at: Time.zone.now,
|
15
|
+
confirmation_token: 'Generated account'
|
16
|
+
})
|
17
|
+
|
18
|
+
if user.save
|
19
|
+
say 'User successfully created'
|
20
|
+
else
|
21
|
+
say 'Error:'
|
22
|
+
user.errors.full_messages.each { |e| say "\t#{e}" }
|
23
|
+
say 'Please try again...'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module PushType
|
4
|
+
describe AuthenticationMethods do
|
5
|
+
|
6
|
+
subject { PushType::AdminController.new }
|
7
|
+
let :before_filters do
|
8
|
+
subject._process_action_callbacks.find_all { |x| x.kind == :before }.map(&:filter)
|
9
|
+
end
|
10
|
+
|
11
|
+
it { subject.methods.include?(:authenticate_user!).must_equal true }
|
12
|
+
it { before_filters.include?(:authenticate_user!).must_equal true }
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module PushType
|
4
|
+
describe ProfilesController do
|
5
|
+
|
6
|
+
let(:current_user) { FactoryGirl.create(:confirmed_user) }
|
7
|
+
before { sign_in current_user }
|
8
|
+
|
9
|
+
describe 'GET #edit' do
|
10
|
+
before { get :edit }
|
11
|
+
it { response.must_render_template 'edit' }
|
12
|
+
it { assigns[:user].must_equal current_user }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'PUT #update' do
|
16
|
+
before { put :update, user: { name: new_name } }
|
17
|
+
|
18
|
+
describe 'with invalid user' do
|
19
|
+
let(:new_name) { '' }
|
20
|
+
it { assigns[:user].errors.wont_be_empty }
|
21
|
+
it { response.must_render_template :edit }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'with valid user' do
|
25
|
+
let(:new_name) { 'Test user ABC' }
|
26
|
+
it { current_user.reload.name.must_equal new_name }
|
27
|
+
it { flash[:notice].must_be :present? }
|
28
|
+
it { response.must_redirect_to edit_profile_path }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module PushType
|
4
|
+
describe UsersController do
|
5
|
+
|
6
|
+
let(:current_user) { FactoryGirl.create(:confirmed_user) }
|
7
|
+
let(:user) { FactoryGirl.create :user }
|
8
|
+
before { sign_in current_user }
|
9
|
+
|
10
|
+
let(:last_email) { ActionMailer::Base.deliveries.last }
|
11
|
+
|
12
|
+
describe 'PUT #invite' do
|
13
|
+
let(:referer) { '/push_type/users' }
|
14
|
+
before do
|
15
|
+
@request.env["HTTP_REFERER"] = referer
|
16
|
+
put :invite, id: user.id
|
17
|
+
end
|
18
|
+
it { response.must_redirect_to referer }
|
19
|
+
it { last_email.to.must_include user.email }
|
20
|
+
it { last_email.subject.must_equal 'Confirmation instructions' }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: b82ba266443adac53a52bc59a1903bcfe5b7cd2e69d38ae378bebc5cdb6ebdeddf692631ad071598f89bb06686a31e358c05bfc26a3c8bfa20826d018ddf1b05
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: 206d2a0a52ed90dab80e01d2a031c099e0fe5d12bc6ed6f3c2af435ff5e89349fa6f8615fc23b5ca953c2efe877254fae32b660b5b149823976caa01bda5d2ae
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150102204447) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|