Skip to content

Commit f7c3a68

Browse files
authored
Merge pull request #160 from timlkelly/fix-customer-login-token-jwt
Fix Bigcommerce::Customer#login_token JWT
2 parents 0aa8f0f + f1fe696 commit f7c3a68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/bigcommerce/resources/customers/customer.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ def self.count(params = {})
3434
# Generate a token that can be used to log the customer into the storefront.
3535
# This requires your app to have the store_v2_customers_login scope and to
3636
# be installed in the store.
37-
def login_token(config: Bigcommerce.config)
37+
def login_token(config: Bigcommerce.config, redirect_to: '/')
3838
payload = {
3939
'iss' => config.client_id,
4040
'iat' => Time.now.to_i,
4141
'jti' => SecureRandom.uuid,
4242
'operation' => 'customer_login',
4343
'store_hash' => config.store_hash,
44-
'customer_id' => id
44+
'customer_id' => id,
45+
'redirect_to' => redirect_to
4546
}
4647

47-
JWT.encode(payload, config.client_secret, 'HS256')
48+
JWT.encode(payload, config.client_secret, 'HS256', { typ: 'JWT' })
4849
end
4950
end
5051
end

0 commit comments

Comments
 (0)