direct_admin 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56f4b3c401671eee31fef798b7148c8b27bc5f50
4
- data.tar.gz: f0da1e4026fd7b53e9bcc2847ed958289e0005fb
3
+ metadata.gz: 12f43b220e83ac9062e827edbb28139e108f8fff
4
+ data.tar.gz: 9fd7c435c917f1355b4cc04b5084eca341662582
5
5
  SHA512:
6
- metadata.gz: 7fbd723f9ee51975c0a73a5a8471897093b62a493d223fe84d1806a12a5e41e2a665c4e9dec646f06a0bd7dc24d666f438aa65e4d50ddd72f636f71398fd782d
7
- data.tar.gz: c7cffe79128d54c819362fffac3658344fad17d0cc05062a5dcd08ee8cc619730b12129f2a139efbadd101dbad8d5cba709c3ddcf46d10ffd9aac03207920a20
6
+ metadata.gz: b8fae7329e435a5956d2753fb17605cb2b1979b8fddf6349e0a65f2b5b59ca4c4c680cf335e43401dd6cce2b1af06bc4c21aba208d93404342f12d0314ebcad8
7
+ data.tar.gz: 6062501f699e5d59eb8781f039c8c376bdd98589f79171d3c56adefbfa25535c371a0cc6698fa0ab3910968e52c95ed00afd0421371b0892587f368a1103f6ce
@@ -31,8 +31,8 @@ module DirectAdmin
31
31
  @password = password
32
32
  end
33
33
 
34
- def _request(method, endpoint, params) # :nodoc:
35
- Request.new(self, method, endpoint, params)
34
+ def request(method, endpoint, params) # :nodoc:
35
+ Request.new(self, method, endpoint, params).call
36
36
  end
37
37
  end
38
38
  end
@@ -47,5 +47,53 @@ module DirectAdmin
47
47
 
48
48
  request(:post, "/CMD_API_LOGIN_KEYS", params)
49
49
  end
50
+
51
+ # Verify the username and password of a user
52
+ #
53
+ # client.verify_password("admin", "secret")
54
+ def verify_password(username, password)
55
+ params = {
56
+ "user" => username,
57
+ "passwd" => password
58
+ }
59
+
60
+ response = request(:post, "/CMD_API_VERIFY_PASSWORD", params)
61
+
62
+ if response.has_key?("valid")
63
+ Integer(response["valid"]) == 1
64
+ end
65
+ end
66
+
67
+ # Authenticate email account. Must be logged in as domain owner for command
68
+ # to be successful.
69
+ #
70
+ # client.email_auth("user@domain.com", "secret")
71
+ def email_auth(email, password)
72
+ params = {
73
+ "email" => email,
74
+ "passwd" => password
75
+ }
76
+
77
+ response = request(:post, "/CMD_API_EMAIL_AUTH", params)
78
+
79
+ if response.has_key?("error")
80
+ Integer(response["error"]) == 0
81
+ end
82
+ end
83
+
84
+ # Owner of domain
85
+ #
86
+ # client.domain_owner("domain.com")
87
+ def domain_owner(domain)
88
+ params = {
89
+ "domain" => domain
90
+ }
91
+
92
+ response = request(:post, "/CMD_API_DOMAIN_OWNERS", params)
93
+
94
+ if response.has_key?(domain)
95
+ response[domain]
96
+ end
97
+ end
50
98
  end
51
99
  end
@@ -5,9 +5,10 @@ require "http"
5
5
 
6
6
  module DirectAdmin
7
7
  class Request
8
- attr_reader :method, :endpont, :params, :url
8
+ attr_reader :client, :method, :endpont, :params, :url
9
9
 
10
10
  def initialize(client, method, endpoint, params)
11
+ @client = client
11
12
  @method = method
12
13
  @endpoint = endpoint
13
14
  @params = params
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module DirectAdmin
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: direct_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Daniels