Browse Source

Fixing per @yknl comments

Signed-off-by: Mary Anthony <mary@blockstack.com>
feat/clarity-updates
Mary Anthony 6 years ago
parent
commit
57e71a6a8e
  1. 9
      _browser/hello-blockstack.md
  2. 5
      _develop/add_auth.md
  3. 3
      _develop/storage.md
  4. 16
      _storage/hello-hub-choice.md

9
_browser/hello-blockstack.md

@ -258,11 +258,12 @@ several states the user can be in:
The application handles these situations as followed:
```js
if (blockstack.isUserSignedIn()) {
var profile = blockstack.UserSession.loadUserData().profile
var userSession = new UserSession()
if (userSession.isUserSignedIn()) {
var profile = userSession.loadUserData().profile
showProfile(profile)
} else if (blockstack.UserSession.isSignInPending()) {
blockstack.UserSession.handlePendingSignIn().then(function(userData) {
} else if (userSession.isSignInPending()) {
userSession.handlePendingSignIn().then(function(userData) {
window.location = window.location.origin
})
}

5
_develop/add_auth.md

@ -51,8 +51,9 @@ To check for the presence of this token, your app should call `UserSession.isSig
```js
import * as blockstack from 'blockstack'
if (blockstack.UserSession.isSignInPending()) {
blockstack.UserSession.handlePendingSignIn()
var userSession = new UserSession()
if (userSession.isSignInPending()) {
userSession.handlePendingSignIn()
.then(userData => {
const profile = userData.profile
})

3
_develop/storage.md

@ -86,7 +86,8 @@ the `publish_data` scope during authentication.
app: 'http://BlockstackApp.com' // origin of the app this file is stored for
}
blockstack.UserSession.getFile("/message.txt", options)
var userSession = new UserSession()
userSession.putFile("/hello.txt", "hello world!", options)
.then((fileContents) => {
// get the contents of the file /message.txt
assert(fileContents === "hello world!")

16
_storage/hello-hub-choice.md

@ -149,13 +149,18 @@ To replace the default login, do the following:
2. Locate the `redirectToSignIn()` method at line 4.
3. Replace `redirectToSignIn()` method with the `blockstack.UserSession.redirectToSignInWithAuthRequest(authRequest)` method.
```javascript
var userSession = new UserSession()
userSession.redirectToSignInWithAuthRequest(authRequest)
```
The `authRequest` is the authentication request generated by `makeAuthRequest()` method.
4. Immediately above the method you just added and below the `event.preventDefault()` method, construct a String `const` for the `authRequest`:
```
const authRequest = blockstack.makeAuthRequest(
blockstack.generateAndStoreTransitKey(),
const authRequest = userSession.makeAuthRequest(
userSession.generateAndStoreTransitKey(),
'http://localhost:8080/',
'http://localhost:8080/manifest.json',
['store_write', 'publish_data'],
@ -245,12 +250,13 @@ import {
redirectToSignInWithAuthRequest
} from 'blockstack';
const authRequest = makeAuthRequest(undefined, undefined, undefined, undefined, undefined, undefined, {
var userSession = new UserSession()
const authRequest = userSession.makeAuthRequest(undefined, undefined, undefined, undefined, undefined, undefined, {
solicitGaiaHubUrl: true,
recommendedGaiaHubUrl: 'https://mygaiahub.com'
});
const authRequest = makeAuthRequest(
const authRequest = userSession.makeAuthRequest(
generateAndStoreTransitKey(),
'http://localhost:8080/',
'http://localhost:8080/manifest.json',
@ -262,7 +268,7 @@ const authRequest = makeAuthRequest(
}
);
redirectToSignInWithAuthRequest(authRequest);
userSession.redirectToSignInWithAuthRequest(authRequest);
```
Passing these parameters changes the storage hub URL prompt to the following:

Loading…
Cancel
Save