ruboty-authorization 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/ruboty/authorization.rb +8 -7
- data/lib/ruboty/authorization/actions/authorize.rb +1 -1
- data/lib/ruboty/authorization/actions/return_user.rb +11 -0
- data/lib/ruboty/authorization/version.rb +1 -1
- data/lib/ruboty/handlers/authorization.rb +8 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d80b0bcd894dd9262aefabebdf5db3e90d7e77a
|
4
|
+
data.tar.gz: 928e0f37108f9619ba9a869f088128aea4f9ad72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c26c3500e0cd2c901bb44f5f2541e0eeef57356c68b68591ebfe1a18ec78ba5cc1178a9fba49ea29e8fd244d64e9c6320c0f516726c444803b66b98ba827245
|
7
|
+
data.tar.gz: 7a58161d8634bd54bebf86b828f535454c19bf4d67112479f6667757eeaed3587bf700a0eec55845fec38e73e0e2e7eeff36d9840dc892a75bd5a1dd4d3f0eee
|
data/README.md
CHANGED
data/lib/ruboty/authorization.rb
CHANGED
@@ -9,12 +9,13 @@ module Ruboty
|
|
9
9
|
class AuthenticationError < StandardError; end
|
10
10
|
|
11
11
|
def call(handler, message, options = {})
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
return false unless !!options[:missing] == missing?
|
13
|
+
return false unless message.match(pattern_with(handler.robot.name))
|
14
|
+
|
15
|
+
authorized!(message)
|
16
|
+
!!handler.send(name, message)
|
17
|
+
rescue => e
|
18
|
+
message.reply(e.message)
|
18
19
|
end
|
19
20
|
|
20
21
|
def authorized!(message)
|
@@ -23,7 +24,7 @@ module Ruboty
|
|
23
24
|
return if [ self.name , owner_name ].include? message.from_name
|
24
25
|
return if @user_list.find_by_name(message.from_name)
|
25
26
|
|
26
|
-
raise AuthenticationError.new("#{message.from_name}
|
27
|
+
raise AuthenticationError.new("#{message.from_name} is not authorized user")
|
27
28
|
end
|
28
29
|
|
29
30
|
def owner_name
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Ruboty::Authorization::Action
|
2
|
+
class ReturnUser < Ruboty::Actions::Base
|
3
|
+
attr_reader :user_list
|
4
|
+
|
5
|
+
def call
|
6
|
+
@user_list = ::Ruboty::Authorization::UserList.new(message.robot.brain)
|
7
|
+
names = @user_list.users.map(&:name).join("\n")
|
8
|
+
message.reply(names)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
require "ruboty/authorization/actions/authorize"
|
2
|
+
require "ruboty/authorization/actions/return_user"
|
2
3
|
|
3
4
|
module Ruboty
|
4
5
|
module Handlers
|
5
6
|
class Authorization < Base
|
6
|
-
on(/authorize
|
7
|
+
on(/authorize\s+(.*)/m, name: 'authorize', description: 'authorize specific user')
|
8
|
+
on(/users\z/, name: 'return_users', description: 'return authorized users name')
|
7
9
|
|
8
10
|
def authorize(message)
|
9
|
-
Ruboty::Authorization::Authorize.new(message).call
|
11
|
+
Ruboty::Authorization::Action::Authorize.new(message).call
|
12
|
+
end
|
13
|
+
|
14
|
+
def return_users(message)
|
15
|
+
Ruboty::Authorization::Action::ReturnUser.new(message).call
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morioka Shuhei
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/ruboty/authorization.rb
|
73
73
|
- lib/ruboty/authorization/actions/authorize.rb
|
74
|
+
- lib/ruboty/authorization/actions/return_user.rb
|
74
75
|
- lib/ruboty/authorization/user.rb
|
75
76
|
- lib/ruboty/authorization/user_list.rb
|
76
77
|
- lib/ruboty/authorization/version.rb
|