oa-webmoney 0.0.1 → 0.0.2
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/README.md +38 -39
- data/oa-webmoney.gemspec +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -1,72 +1,72 @@
|
|
1
|
-
|
1
|
+
# oa-webmoney
|
2
2
|
|
3
|
-
|
3
|
+
## Usage with Devise
|
4
4
|
|
5
5
|
Original help page[https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview]
|
6
6
|
|
7
7
|
Gemfile
|
8
8
|
|
9
|
-
|
9
|
+
gem 'oa-webmoney'
|
10
10
|
|
11
|
-
|
11
|
+
You should add wmid column:
|
12
12
|
|
13
|
-
|
13
|
+
rails g migration add_wmid_to_user
|
14
14
|
|
15
|
-
and add
|
15
|
+
and add code below to created migration:
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
def self.up
|
18
|
+
add_column :users, :wmid, :string, :limit => 12
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
add_index :users, :wmid, :unique => true
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def self.down
|
24
|
+
remove_column :users, :wmid
|
25
|
+
end
|
26
26
|
|
27
27
|
devise.rb
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
config.omniauth :webmoney, :credentials => { :site_holder_wmid => 'your_site_wmid',
|
30
|
+
:app_rids => { 'localhost' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
31
|
+
'example.com' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }}, :mode => Rails.env)
|
32
32
|
|
33
33
|
user.rb
|
34
34
|
|
35
|
-
|
35
|
+
devise :omniauthable
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def self.find_for_webmoney_oauth(access_token, signed_in_resource=nil)
|
38
|
+
data = access_token['extra']
|
39
|
+
if user = User.find_by_wmid(data[:WmLogin_WMID])
|
40
|
+
user
|
41
|
+
else # Create an user with a stub password.
|
42
|
+
User.create!(:email => "#{data[:WmLogin_WMID]}@wmkeeper.com", :password => Devise.friendly_token[0,20])
|
43
|
+
end
|
43
44
|
end
|
44
|
-
end
|
45
45
|
|
46
46
|
add link to authorize:
|
47
47
|
|
48
|
-
|
48
|
+
<%= link_to "Sign in with Webmoney", user_omniauth_authorize_path(:webmoney) %>
|
49
49
|
|
50
50
|
routes.rb
|
51
51
|
|
52
|
-
|
52
|
+
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
53
53
|
|
54
54
|
app/controllers/users/omniauth_callbacks_controller.rb
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
57
|
+
def webmoney
|
58
|
+
# You need to implement the method below in your model
|
59
|
+
@user = User.find_for_webmoney_oauth(env["omniauth.auth"], current_user)
|
60
|
+
|
61
|
+
if @user.persisted?
|
62
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Webmoney"
|
63
|
+
sign_in_and_redirect @user, :event => :authentication
|
64
|
+
else
|
65
|
+
session["devise.webmoney_data"] = env["omniauth.auth"]
|
66
|
+
redirect_to new_user_registration_url
|
67
|
+
end
|
67
68
|
end
|
68
69
|
end
|
69
|
-
end
|
70
70
|
|
71
71
|
== Contributing to oa-webmoney
|
72
72
|
|
@@ -82,4 +82,3 @@ app/controllers/users/omniauth_callbacks_controller.rb
|
|
82
82
|
|
83
83
|
Copyright (c) 2011 Anton. See LICENSE.txt for
|
84
84
|
further details.
|
85
|
-
|
data/oa-webmoney.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{oa-webmoney}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anton"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-01}
|
13
13
|
s.description = %q{Webmoney}
|
14
14
|
s.email = %q{eagle.anton@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Anton
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-03-01 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
hash: -
|
149
|
+
hash: -801320365
|
150
150
|
segments:
|
151
151
|
- 0
|
152
152
|
version: "0"
|