adva-user 0.0.9 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/admin/base_controller_slice.rb +3 -3
- data/app/controllers/user/registrations_controller.rb +10 -0
- data/app/controllers/user/sessions_controller.rb +1 -1
- data/app/models/user.rb +4 -0
- data/app/views/user/confirmations/new.html.rb +2 -1
- data/app/views/user/form.rb +2 -2
- data/app/views/user/passwords/edit.html.rb +2 -1
- data/app/views/user/registrations/new.html.rb +4 -2
- data/app/views/user/sessions/new.html.rb +1 -0
- data/app/views/user/unlocks/new.html.rb +2 -1
- data/config/locales/en.yml +5 -0
- data/lib/adva/user.rb +4 -3
- data/lib/adva_user/authorization.rb +15 -0
- data/lib/adva_user/version.rb +1 -1
- data/lib/testing/factories.rb +5 -2
- data/lib/testing/step_definitions.rb +23 -13
- metadata +33 -29
@@ -1,3 +1,13 @@
|
|
1
1
|
class User::RegistrationsController < Devise::RegistrationsController
|
2
2
|
layout 'user'
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def after_inactive_sign_up_path_for(resource)
|
7
|
+
if resource.is_a?(User)
|
8
|
+
params[:return_to] || new_user_session_path
|
9
|
+
else
|
10
|
+
raise "unknown resource: #{resource}"
|
11
|
+
end
|
12
|
+
end
|
3
13
|
end
|
data/app/models/user.rb
CHANGED
@@ -6,6 +6,7 @@ class User::Confirmations::New < User::Form
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def fields
|
9
|
+
super
|
9
10
|
form.input :email
|
10
11
|
end
|
11
12
|
|
@@ -13,4 +14,4 @@ class User::Confirmations::New < User::Form
|
|
13
14
|
[resource, { :as => resource_name, :url => confirmation_path(resource_name) }]
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
data/app/views/user/form.rb
CHANGED
@@ -48,8 +48,8 @@ class User::Form < Adva::View::Form
|
|
48
48
|
capture { link_to(:'user.links.sign_in', new_session_path(resource_name), :class => :sign_in) }
|
49
49
|
end
|
50
50
|
|
51
|
-
def sign_up_link
|
52
|
-
capture { link_to(:'user.links.sign_up', new_registration_path(resource_name), :class => :sign_up) }
|
51
|
+
def sign_up_link(options={}, html_options={})
|
52
|
+
capture { link_to(:'user.links.sign_up', new_registration_path(resource_name, options), { :class => :sign_up }.merge(html_options)) }
|
53
53
|
end
|
54
54
|
|
55
55
|
def forgot_password_link
|
@@ -6,6 +6,7 @@ class User::Passwords::Edit < User::Form
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def fields
|
9
|
+
super
|
9
10
|
form.hidden_field :reset_password_token
|
10
11
|
form.input :password
|
11
12
|
form.input :password_confirmation
|
@@ -15,4 +16,4 @@ class User::Passwords::Edit < User::Form
|
|
15
16
|
[resource, { :as => resource_name, :url => password_path(resource_name), :html => { :method => :put } }]
|
16
17
|
end
|
17
18
|
end
|
18
|
-
end
|
19
|
+
end
|
@@ -6,13 +6,15 @@ class User::Registrations::New < User::Form
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def fields
|
9
|
+
super
|
10
|
+
pass_return_to
|
9
11
|
form.input :email
|
10
12
|
form.input :password
|
11
|
-
form.input :password_confirmation
|
13
|
+
form.input :password_confirmation, :required => true
|
12
14
|
end
|
13
15
|
|
14
16
|
def form_arguments
|
15
17
|
[resource, { :as => resource_name, :url => registration_path(resource_name) }]
|
16
18
|
end
|
17
19
|
end
|
18
|
-
end
|
20
|
+
end
|
@@ -6,6 +6,7 @@ class User::Unlocks::New < User::Form
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def fields
|
9
|
+
super
|
9
10
|
form.input :email
|
10
11
|
end
|
11
12
|
|
@@ -13,4 +14,4 @@ class User::Unlocks::New < User::Form
|
|
13
14
|
[resource, { :as => resource_name, :url => unlock_path(resource_name) }]
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
data/config/locales/en.yml
CHANGED
@@ -59,7 +59,9 @@ en:
|
|
59
59
|
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
60
60
|
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
61
61
|
registrations:
|
62
|
+
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}. A confirmation was sent to your e-mail.'
|
62
63
|
signed_up: 'You have signed up successfully. A confirmation was sent to your e-mail.'
|
64
|
+
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}. A confirmation was sent to your e-mail.'
|
63
65
|
updated: 'You updated your account successfully.'
|
64
66
|
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
65
67
|
unlocks:
|
@@ -85,3 +87,6 @@ en:
|
|
85
87
|
sign_in: Sign in
|
86
88
|
sign_up: Sign up
|
87
89
|
sign_out: Sign out %{user}
|
90
|
+
flash:
|
91
|
+
admin:
|
92
|
+
access_denied: "Access Denied"
|
data/lib/adva/user.rb
CHANGED
@@ -7,14 +7,15 @@ module Adva
|
|
7
7
|
|
8
8
|
# TODO [config] should probably happen in the client app
|
9
9
|
# for more devise options see http://bit.ly/bwxrGg
|
10
|
-
initializer 'adva-user.devise_setup' do |app|
|
10
|
+
initializer 'adva-user.devise_setup', :before => 'action_mailer.set_configs' do |app|
|
11
11
|
|
12
12
|
# FIXME [config]
|
13
|
-
app.config.action_mailer.default_url_options
|
13
|
+
app.config.action_mailer.default_url_options ||= {}
|
14
|
+
app.config.action_mailer.default_url_options.reverse_merge!({ :host => 'www.example.com' })
|
14
15
|
|
15
16
|
Devise.setup do |config|
|
16
17
|
require 'devise/orm/active_record'
|
17
|
-
config.mailer_sender
|
18
|
+
config.mailer_sender ||= 'please-change-me@config-initializers-devise.com'
|
18
19
|
config.encryptor = :bcrypt
|
19
20
|
config.password_length = 5..20
|
20
21
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AdvaUser
|
2
|
+
module Authorization
|
3
|
+
def self.included(controller)
|
4
|
+
controller.class_eval do
|
5
|
+
before_filter :authorize_user!
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def authorize_user!
|
10
|
+
unless current_user.admin?
|
11
|
+
redirect_to root_url, :flash => {:alert => I18n.translate('flash.admin.access_denied')}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/adva_user/version.rb
CHANGED
data/lib/testing/factories.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
Factory::DefaultPassword = 'secret'
|
2
|
+
|
1
3
|
Factory.define :user, :class => User do |f|
|
2
4
|
f.sequence(:email) { |n| "user-#{n}@example.com" }
|
3
|
-
f.password
|
5
|
+
f.password Factory::DefaultPassword
|
4
6
|
f.after_build { |user| User.deactivate_callbacks }
|
5
7
|
f.after_create { |user| user.confirm!; User.activate_callbacks }
|
6
8
|
end
|
7
9
|
|
8
10
|
Factory.define :admin, :parent => :user do |f|
|
11
|
+
# FIXME should be possible to create more than one admin
|
9
12
|
f.email { User.find_by_email('admin@admin.org') ? 'admin-2@admin.org' : 'admin@admin.org' }
|
10
|
-
f.
|
13
|
+
f.roles %w(admin)
|
11
14
|
end
|
@@ -1,16 +1,9 @@
|
|
1
|
-
Given /^I am signed in with "([^"]*)" and "([^"]*)"$/ do |email, password|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# Please, use the step 'Given I am signed in with "admin@admin.org" and "admin!"' in all
|
8
|
-
# other features for performance reasons.
|
9
|
-
Given /^I sign in with "([^"]*)" and "([^"]*)"$/ do |email, password|
|
10
|
-
get new_user_session_path
|
11
|
-
fill_in 'Email', :with => email
|
12
|
-
fill_in 'Password', :with => password
|
13
|
-
click_button 'Sign in'
|
1
|
+
Given /^I (?:am signed|sign) in with "([^"]*)" and "([^"]*)"$/ do |email, password|
|
2
|
+
Given %Q~I am on the sign in page~
|
3
|
+
# use ids to be flexible about label changes
|
4
|
+
When %Q~I fill in "user_email" with "#{email}"~
|
5
|
+
And %Q~I fill in "user_password" with "#{password}"~
|
6
|
+
And %Q~I press "Sign in"~
|
14
7
|
@user = User.find_by_email(email)
|
15
8
|
end
|
16
9
|
|
@@ -23,3 +16,20 @@ Then 'I should be signed in' do
|
|
23
16
|
When 'I go to the sign in page'
|
24
17
|
Then 'I should be on the homepage'
|
25
18
|
end
|
19
|
+
|
20
|
+
# Two ways to use:
|
21
|
+
# Given I am logged in as admin
|
22
|
+
# => created the admin and login
|
23
|
+
# Given a user "Peter" exists with email: "peter-lustig@example.com"
|
24
|
+
# And I am logged in as the user "Peter"
|
25
|
+
# => uses the prepared user to log in
|
26
|
+
#
|
27
|
+
# Please set the passwort if the user only for auth tests
|
28
|
+
Given /^I (?:am signed|sign) in as #{capture_model}$/ do |user|
|
29
|
+
unless user.include?('the') || user.include?('"')
|
30
|
+
Given %{#{user} exists}
|
31
|
+
end
|
32
|
+
user = model!(user)
|
33
|
+
And %Q~I am signed in with "#{user.email}" and "#{Factory::DefaultPassword}"~
|
34
|
+
end
|
35
|
+
|
metadata
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adva-user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Ingo Weiss
|
14
13
|
- Sven Fuchs
|
14
|
+
- Ingo Weiss
|
15
|
+
- Raphaela Wrede
|
16
|
+
- Matthias Viehweger
|
17
|
+
- Niklas Hofer
|
18
|
+
- Chris Floess
|
19
|
+
- Johannes Strampe
|
15
20
|
autorequire:
|
16
21
|
bindir: bin
|
17
22
|
cert_chain: []
|
18
23
|
|
19
|
-
date: 2011-
|
20
|
-
default_executable:
|
24
|
+
date: 2011-07-29 00:00:00 Z
|
21
25
|
dependencies:
|
22
26
|
- !ruby/object:Gem::Dependency
|
23
27
|
name: adva-core
|
@@ -41,15 +45,15 @@ dependencies:
|
|
41
45
|
requirements:
|
42
46
|
- - "="
|
43
47
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
48
|
+
hash: 19
|
45
49
|
segments:
|
46
50
|
- 1
|
47
|
-
-
|
48
|
-
-
|
49
|
-
version: 1.
|
51
|
+
- 3
|
52
|
+
- 4
|
53
|
+
version: 1.3.4
|
50
54
|
type: :runtime
|
51
55
|
version_requirements: *id002
|
52
|
-
description: User engine for adva-cms2
|
56
|
+
description: User engine for adva-cms2.
|
53
57
|
email: nobody@adva-cms.org
|
54
58
|
executables: []
|
55
59
|
|
@@ -58,38 +62,38 @@ extensions: []
|
|
58
62
|
extra_rdoc_files: []
|
59
63
|
|
60
64
|
files:
|
65
|
+
- app/controllers/admin/base_controller_slice.rb
|
66
|
+
- app/controllers/installations_controller_slice.rb
|
67
|
+
- app/controllers/user/confirmations_controller.rb
|
61
68
|
- app/controllers/user/passwords_controller.rb
|
69
|
+
- app/controllers/user/registrations_controller.rb
|
62
70
|
- app/controllers/user/sessions_controller.rb
|
63
71
|
- app/controllers/user/unlocks_controller.rb
|
64
|
-
- app/
|
65
|
-
- app/
|
66
|
-
- app/controllers/installations_controller_slice.rb
|
67
|
-
- app/controllers/admin/base_controller_slice.rb
|
68
|
-
- app/views/layouts/user.rb
|
72
|
+
- app/models/account_slice.rb
|
73
|
+
- app/models/user.rb
|
69
74
|
- app/views/layouts/admin/_header_slice.rb
|
70
|
-
- app/views/user
|
71
|
-
- app/views/
|
75
|
+
- app/views/layouts/user.rb
|
76
|
+
- app/views/mailer/confirmation_instructions.html.erb
|
77
|
+
- app/views/mailer/reset_password_instructions.html.erb
|
78
|
+
- app/views/mailer/unlock_instructions.html.erb
|
79
|
+
- app/views/user/confirmations/new.html.rb
|
80
|
+
- app/views/user/form.rb
|
72
81
|
- app/views/user/passwords/edit.html.rb
|
73
82
|
- app/views/user/passwords/new.html.rb
|
74
|
-
- app/views/user/form.rb
|
75
|
-
- app/views/user/confirmations/new.html.rb
|
76
83
|
- app/views/user/registrations/edit.html.rb
|
77
84
|
- app/views/user/registrations/new.html.rb
|
78
|
-
- app/views/
|
79
|
-
- app/views/
|
80
|
-
- app/views/mailer/reset_password_instructions.html.erb
|
81
|
-
- app/models/user.rb
|
82
|
-
- app/models/account_slice.rb
|
83
|
-
- config/routes.rb
|
85
|
+
- app/views/user/sessions/new.html.rb
|
86
|
+
- app/views/user/unlocks/new.html.rb
|
84
87
|
- config/locales/en.yml
|
88
|
+
- config/routes.rb
|
89
|
+
- lib/adva/user.rb
|
85
90
|
- lib/adva-user.rb
|
91
|
+
- lib/adva_user/authorization.rb
|
86
92
|
- lib/adva_user/version.rb
|
87
|
-
- lib/adva/user.rb
|
88
93
|
- lib/testing/factories.rb
|
89
94
|
- lib/testing/paths.rb
|
90
95
|
- lib/testing/step_definitions.rb
|
91
96
|
- public/stylesheets/adva-user/user.css
|
92
|
-
has_rdoc: true
|
93
97
|
homepage: http://github.com/svenfuchs/adva-cms2
|
94
98
|
licenses: []
|
95
99
|
|
@@ -119,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
123
|
requirements: []
|
120
124
|
|
121
125
|
rubyforge_project: "[none]"
|
122
|
-
rubygems_version: 1.
|
126
|
+
rubygems_version: 1.8.6
|
123
127
|
signing_key:
|
124
128
|
specification_version: 3
|
125
129
|
summary: User engine for adva-cms2
|