Skip to content

Commit 91e9bb9

Browse files
feat: include tags in the user data inside the request (#515)
1 parent 7ee31ad commit 91e9bb9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

app/services/forest_liana/token.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def self.create_token(user, rendering_id)
2020
last_name: user['last_name'],
2121
team: user['teams'][0],
2222
role: user['role'],
23+
tags: user['tags'],
2324
rendering_id: rendering_id,
2425
exp: expiration_in_seconds()
2526
}, ForestLiana.auth_secret, 'HS256')

spec/requests/authentications_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
describe "GET /authentication/callback" do
4747
before() do
48-
response = '{"data":{"id":666,"attributes":{"first_name":"Alice","last_name":"Doe","email":"[email protected]","teams":[1,2,3],"role":"Test"}}}'
48+
response = '{"data":{"id":666,"attributes":{"first_name":"Alice","last_name":"Doe","email":"[email protected]","teams":[1,2,3],"role":"Test","tags":[{"key":"city","value":"Paris"}]}}}'
4949
allow(ForestLiana::ForestApiRequester).to receive(:get).with(
5050
"/liana/v2/renderings/42/authorization", { :headers => { "forest-token" => "THE-ACCESS-TOKEN" }, :query=> {} }
5151
).and_return(
@@ -76,6 +76,10 @@
7676
}
7777

7878
expect(decoded).to include(expected_token_data)
79+
tags = decoded['tags']
80+
expect(tags.length).to eq(1)
81+
expect(tags[0]['key']).to eq("city")
82+
expect(tags[0]['value']).to eq("Paris")
7983
expect(body).to eq({ token: token, tokenData: decoded.deep_symbolize_keys! })
8084
expect(response).to have_http_status(200)
8185
end

0 commit comments

Comments
 (0)