Skip to content

Commit ef9eef5

Browse files
committed
Update user config.
1 parent cec4d2e commit ef9eef5

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ cd extract
6161
mkdir users
6262
6363
# use your own secret key and username
64-
echo "SECRET_KEY" > users/USERNAME
64+
echo "user: key" > users/users.yml
6565
```
6666

6767
Once a username and password has been created, you can make a request.

app/app.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require "openssl"
66
require "base64"
77
require "connection_pool"
8+
require "yaml"
89

910
set :protection, except: [:json_csrf]
1011

@@ -14,13 +15,7 @@
1415

1516
$users = begin
1617
if ENV["EXTRACT_USERS"]
17-
File.readlines(ENV["EXTRACT_USERS"]).each_with_object({}) do |line, hash|
18-
line = line.strip
19-
next if line.empty?
20-
21-
username, password = line.split("=", 2)
22-
hash[username] = password if username && password
23-
end
18+
YAML.safe_load_file(ENV["EXTRACT_USERS"])
2419
else
2520
{"demo" => "demo"}
2621
end

test/test_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
USERS = Tempfile.new
2-
USERS.write("user=key")
2+
USERS.write("user: key")
33
USERS.close
44

55
ENV["RACK_ENV"] = "test"
@@ -31,7 +31,7 @@ class Test < Minitest::Test
3131
include Rack::Test::Methods
3232

3333
def setup
34-
@user, @key = File.read(USERS).split("=", 2)
34+
@user, @key = YAML.safe_load_file(USERS).first
3535
end
3636

3737
def app

0 commit comments

Comments
 (0)