Permalink
Browse files

Fix: session.details to match with session sent in the request.

  • Loading branch information...
1 parent 1cf0f91 commit 498f6f97dc92e445565e5ddd98444d0bd3a63014 @danielstieber danielstieber committed with dblock Apr 15, 2017
Showing with 40 additions and 11 deletions.
  1. +3 −2 CHANGELOG.md
  2. +1 −0 README.md
  3. +26 −0 UPGRADING.md
  4. +7 −8 index.js
  5. +3 −1 test/fixtures/intent_request_airport_info.json
View
@@ -2,10 +2,11 @@
### 4.0.1 (Next)
+* [#215](https://github.com/alexa-js/alexa-app/pull/215): Fixed `session.details` to match with session in the request object - [@danielstieber](https://github.com/danielstieber).
* [#223](https://github.com/alexa-js/alexa-app/issues/223): Added support for `AskForPermissionsConsent` cards - [@ericblade](https://github.com/ericblade).
* [#219](https://github.com/alexa-js/alexa-app/pull/219): Preserve session when clearing non-existent attribute - [@adrianba](https://github.com/adrianba).
-* [#218](https://github.com/alexa-js/alexa-app/pull/218): Fix cert check test cases - [@adrianba](https://github.com/adrianba).
-* [#220](https://github.com/alexa-js/alexa-app/pull/220): No longer compatible with Node 0.12 - [@adrianba](https://github.com/adrianba).
+* [#218](https://github.com/alexa-js/alexa-app/pull/218): Fix cert check test cases - [@adrianba](https://github.com/adrianba).
+* [#220](https://github.com/alexa-js/alexa-app/pull/220): No longer compatible with Node 0.12 - [@adrianba](https://github.com/adrianba).
### 4.0.0 (March 20, 2017)
* [#134](https://github.com/alexa-js/alexa-app/issues/134): Asynchronous support purely through Promises, removed `return false`/callback support - [@ajcrites](https://github.com/ajcrites).
View
@@ -251,6 +251,7 @@ session.set(String attributeName, String attributeValue)
String session.get(String attributeName)
// session details, as passed by Amazon in the request
+// for Object definition @see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#session-object
session.details = { ... }
```
View
@@ -1,5 +1,31 @@
# Upgrading Alexa-app
+### Upgrading to >= 4.0.1
+
+#### Changes session details syntax
+
+The session details now match the session object in the request. User data has therefore changed and the old methods deprecated, specifically `userId` and `accessToken`.
+
+Before:
+
+```javascript
+// Get userId (marked as deprecated)
+request.getSession().details.userId;
+// Get accessToken (marked as deprecated)
+request.getSession().details.accessToken;
+```
+
+After:
+
+```javascript
+// Get userId
+request.getSession().details.user.userId;
+// Get accessToken
+request.getSession().details.user.accessToken;
+```
+
+See [#215](https://github.com/alexa-js/alexa-app/pull/215) for more information.
+
### Upgrading to >= 4.0.0
#### Changes to Asynchronous Support
View
@@ -264,14 +264,13 @@ alexa.session = function(session) {
this.attributes = {};
}
};
- this.details = {
- "new": session.new,
- "sessionId": session.sessionId,
- "userId": session.user.userId,
- "accessToken": session.user.accessToken || null,
- "attributes": session.attributes,
- "application": session.application
- };
+ // load the alexa session information into details
+ this.details = session;
+ // @deprecated
+ this.details.userId = this.details.user.userId || null;
+ // @deprecated
+ this.details.accessToken = this.details.user.accessToken || null;
+
// persist all the session attributes across requests
// the Alexa API doesn't think session variables should persist for the entire
// duration of the session, but I do
@@ -9,7 +9,9 @@
"attributes": {},
"user": {
"userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2"
- }
+ },
+ "userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2",
+ "accessToken": null
},
"request": {
"type": "IntentRequest",

0 comments on commit 498f6f9

Please sign in to comment.