Commit d753d20f authored by Pavel Mashliakovskiy's avatar Pavel Mashliakovskiy 🤹🏻

`SignatureVerificationResult` view: in case signature is invalid and library...

`SignatureVerificationResult` view: in case signature is invalid and library provide some reason this reason will be shown in `()`
parent 1f06d432
......@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
### Changed
- nodeJS usage example (in a README.md) rewritten using `async function`
### Deprecated
......
......@@ -6,39 +6,51 @@ NodeJS example:
```javascript
global.XMLHttpRequest = require('xhr2')
const UB = require('@unitybase/ub-pub')
let conn = UB.connect({
host: 'http://localhost:8881',
onCredentialRequired: function (conn, isRepeat) {
if (isRepeat) {
throw new UB.UBAbortError('invalid credential')
} else {
return Promise.resolve({authSchema: 'UB', login: 'admin', password: 'admin'})
const HOST = process.env.UB_HOST || 'http://localhost:8881'
const USER = process.env.UB_USER || 'admin'
const PWD = process.env.UB_PWD || 'admin'
async function call_ub () {
const conn = await UB.connect({
host: HOST,
onCredentialRequired: function (conn, isRepeat) {
if (isRepeat) {
throw new UB.UBAbortError('invalid credential')
} else {
return Promise.resolve({authSchema: 'UB', login: USER, password: PWD})
}
},
onAuthorizationFail: function (reason) {
console.error(reason)
}
},
onAuthorizationFail: function (reason) {
console.error(reason)
}
})
conn.then(function (conn) {
})
console.log(`
Hello, ${conn.userLogin()}!
We know that you are ${JSON.stringify(conn.userData())}
`)
Hello, ${conn.userLogin()}!
We know that you are ${JSON.stringify(conn.userData(), null, ' ')}
`)
conn.get('stat').then(function (statResp) {
console.log('Current server statistics:', statResp.data)
})
conn.Repository('ubm_navshortcut').attrs(['ID', 'code', 'caption'])
.limit(2)
.selectAsObject()
.then(function (data) {
console.log('First 2 adminUI shortcuts:')
console.log(JSON.stringify(data, null, '\t'))
})
})
const items = await conn.Repository('ubm_navshortcut').attrs(['ID', 'code', 'caption'])
.limit(2)
.selectAsObject()
.then(function (data) {
console.log('First 2 adminUI shortcuts:')
console.log(JSON.stringify(data, null, '\t'))
})
console.table(items)
}
try {
call_ub()
} catch (e) {
console.error(e)
}
```
The same code as above will work in browser (just comment first line
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment