devise_invitations 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +12 -6
- data/devise_invitations.gemspec +1 -1
- data/lib/devise_invitations/controller.rb +12 -5
- data/lib/devise_invitations/version.rb +1 -1
- metadata +6 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91bd073ebc856b96f8e2f0541c39983cedc74799
|
4
|
+
data.tar.gz: 93f4bfb68faec7e739d1f1d36010c6fcbeab6291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac6278daf78658be5d5229c358225b241fbbfb56434c280eb822072fbc74a09fd2049f4f83bc45c650a0692eaf1015f42b8695cf86681bbf43b2073a607c03f
|
7
|
+
data.tar.gz: e8e2880cf12d27ef549ff7eb96941fac48f9009d08fd91c890f8ba4ac1ada873682a91966ae538c9eeaeba0543fd973e3178030ac77f8bd2ae7eb458877e2ae7
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devise_invitations (0.
|
4
|
+
devise_invitations (0.2)
|
5
5
|
devise_invitable (~> 1.5)
|
6
6
|
faker (~> 1.6)
|
7
7
|
has_secure_token (~> 1.0)
|
8
|
-
shoulda-matchers (
|
8
|
+
shoulda-matchers (>= 2.8)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
arel (6.0.3)
|
49
49
|
bcrypt (3.1.10)
|
50
50
|
builder (3.2.2)
|
51
|
-
devise (3.5.
|
51
|
+
devise (3.5.5)
|
52
52
|
bcrypt (~> 3.0)
|
53
53
|
orm_adapter (~> 0.1)
|
54
54
|
railties (>= 3.2.6, < 5)
|
@@ -73,8 +73,8 @@ GEM
|
|
73
73
|
mime-types (>= 1.16, < 3)
|
74
74
|
mime-types (2.99)
|
75
75
|
mini_portile2 (2.0.0)
|
76
|
-
minitest (5.8.
|
77
|
-
nokogiri (1.6.7.
|
76
|
+
minitest (5.8.4)
|
77
|
+
nokogiri (1.6.7.2)
|
78
78
|
mini_portile2 (~> 2.0.0.rc2)
|
79
79
|
orm_adapter (0.5.0)
|
80
80
|
rack (1.6.4)
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Circle CI](https://circleci.com/gh/RoxasShadow/devise_invitations.svg?style=svg)](https://circleci.com/gh/RoxasShadow/devise_invitations)
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
devise_invitations
|
4
|
+
=================
|
5
5
|
Allow multiple invitations on top of [devise_invitable](https://github.com/scambra/devise_invitable).
|
6
6
|
|
7
7
|
Why?
|
@@ -17,7 +17,7 @@ So let's create a new table that allows an email address to be invited multiple
|
|
17
17
|
|
18
18
|
But *devise_invitable* is useful!
|
19
19
|
---------------------------------
|
20
|
-
I know, in fact I'm creating nothing but a layer on top of it.
|
20
|
+
I know, in fact I'm creating nothing but a layer on top of it. As *devise_invitations* is not a replacement, *devise_invitable* is still needed (well, we could rid it off anyway, PRs are welcomed!)
|
21
21
|
|
22
22
|
Setup
|
23
23
|
-----
|
@@ -33,8 +33,6 @@ This is what's new in your project:
|
|
33
33
|
- A `has_many` association for `User` (useful to fetch the sent invitations) is injected
|
34
34
|
- A new route for said action is injected as well
|
35
35
|
|
36
|
-
If you need to customize something feel free to hard-copy it into your project (i.e. the mailer and the related view).
|
37
|
-
|
38
36
|
If you use *RSpec* and *FactoryGirl* you can run `$ bin/rails g devise_invitations:specs` to copy the specs for the new associations, controllers and models to your codebase. You can extend and customize them as you wish.
|
39
37
|
|
40
38
|
Now, you need an action to let your users invite other ones. Basically it's just
|
@@ -43,4 +41,12 @@ Now, you need an action to let your users invite other ones. Basically it's just
|
|
43
41
|
DeviseInvitations::Invitation.create!(email: params[:email], sent_by: current_user)
|
44
42
|
```
|
45
43
|
|
46
|
-
|
44
|
+
Customization
|
45
|
+
-------------
|
46
|
+
|
47
|
+
You can add new columns to the `invitations` table to add new new attributes too, like `user_type`, `welcome_message` or whatever you want.
|
48
|
+
Create a new class `InvitationsController` that extends the original `DeviseInvitations::InvitationsController`, and override the private method `#invitation_params` to inject these additional attributes. Remember to edit the controller used for handling the invitations in the related route.
|
49
|
+
|
50
|
+
To modify the content of the invitation email, what you need is just a view called `instructions` (use the template engine you prefer) placed inside `app/views/invitation_mailer/`.
|
51
|
+
|
52
|
+
Locales are stored in `config/locales/devise_invitations.en.yml`.
|
data/devise_invitations.gemspec
CHANGED
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_dependency 'devise_invitable', '~> 1.5'
|
19
19
|
s.add_dependency 'has_secure_token', '~> 1.0'
|
20
|
-
s.add_dependency 'shoulda-matchers', '
|
20
|
+
s.add_dependency 'shoulda-matchers', '>= 2.8'
|
21
21
|
s.add_dependency 'faker', '~> 1.6'
|
22
22
|
end
|
@@ -3,11 +3,12 @@ class DeviseInvitations::InvitationsController < Devise::InvitationsController
|
|
3
3
|
invitation = DeviseInvitations::Invitation.pending.find_by(token: params[:token])
|
4
4
|
|
5
5
|
if invitation.present? && invitation.valid?
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
user = User.invite!(
|
7
|
+
invitation_params(invitation).merge(
|
8
|
+
skip_invitation: true
|
9
|
+
),
|
10
|
+
invitation.sent_by
|
11
|
+
)
|
11
12
|
|
12
13
|
user.update(invitation_sent_at: Time.now.utc)
|
13
14
|
|
@@ -23,4 +24,10 @@ class DeviseInvitations::InvitationsController < Devise::InvitationsController
|
|
23
24
|
redirect_to root_path
|
24
25
|
end
|
25
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def invitation_params(invitation)
|
31
|
+
{ email: invitation.email }
|
32
|
+
end
|
26
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roxas Shadow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise_invitable
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: shoulda-matchers
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: faker
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,14 +88,10 @@ files:
|
|
88
88
|
- lib/devise_invitations/mailer.rb
|
89
89
|
- lib/devise_invitations/model.rb
|
90
90
|
- lib/devise_invitations/version.rb
|
91
|
-
- lib/generators/devise_invitations/.DS_Store
|
92
91
|
- lib/generators/devise_invitations/install_generator.rb
|
93
|
-
- lib/generators/devise_invitations/migrations/.DS_Store
|
94
92
|
- lib/generators/devise_invitations/migrations/templates/migration.rb
|
95
|
-
- lib/generators/devise_invitations/models/.DS_Store
|
96
93
|
- lib/generators/devise_invitations/models/templates/associations.rb
|
97
94
|
- lib/generators/devise_invitations/routes/templates/routes.rb
|
98
|
-
- lib/generators/devise_invitations/specs/.DS_Store
|
99
95
|
- lib/generators/devise_invitations/specs/templates/association.rb
|
100
96
|
- lib/generators/devise_invitations/specs/templates/controller.rb
|
101
97
|
- lib/generators/devise_invitations/specs/templates/factory.rb
|