Comparing version 1.5.0 to 1.5.1
@@ -5,2 +5,6 @@ # Changelog | ||
## [1.5.1][] - 2021-02-19 | ||
- Fix restore session for Channel | ||
## [1.5.0][] - 2021-02-19 | ||
@@ -56,3 +60,4 @@ | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.5.0...HEAD | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.5.1...HEAD | ||
[1.5.1]: https://github.com/metarhia/metacom/compare/v1.5.0...v1.5.1 | ||
[1.5.0]: https://github.com/metarhia/metacom/compare/v1.4.0...v1.5.0 | ||
@@ -59,0 +64,0 @@ [1.4.0]: https://github.com/metarhia/metacom/compare/v1.3.1...v1.4.0 |
@@ -85,9 +85,10 @@ 'use strict'; | ||
let session = sessions.get(token); | ||
if (session) return session; | ||
const channel = channels.get(this); | ||
const data = await channel.application.auth.restoreSession(token); | ||
if (!data) return null; | ||
session = new Session(token, channel, data); | ||
if (!session) { | ||
const data = await channel.application.auth.restoreSession(token); | ||
if (!data) return null; | ||
session = new Session(token, channel, data); | ||
sessions.set(token, session); | ||
} | ||
channel.session = session; | ||
sessions.set(token, session); | ||
return session; | ||
@@ -202,4 +203,3 @@ } | ||
const context = session ? session.context : { client }; | ||
const publicMethod = proc.access === 'public'; | ||
if (!this.session && !publicMethod) { | ||
if (!this.session && !proc.access === 'public') { | ||
this.error(403, null, callId); | ||
@@ -216,3 +216,3 @@ return; | ||
} | ||
this.reply(callId, result, publicMethod); | ||
this.reply(callId, result); | ||
const record = `${this.ip}\t${interfaceName}/${methodName}`; | ||
@@ -222,13 +222,8 @@ application.console.log(record); | ||
reply(callId, result, publicMethod) { | ||
reply(callId, result) { | ||
const { res, connection, application } = this; | ||
if (result instanceof Error) { | ||
if (result instanceof application.Error) { | ||
this.error(result.code, result, callId); | ||
return; | ||
} | ||
const id = result ? result.systemUserId : 0; | ||
if (!this.session && id && publicMethod) { | ||
this.session = application.auth.startSession(this, id); | ||
result.token = this.token; | ||
} | ||
const data = JSON.stringify({ callback: callId, result }); | ||
@@ -235,0 +230,0 @@ if (connection) { |
{ | ||
"name": "metacom", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Communication protocol for Metarhia stack with rpc, events, binary streams, memory and db access", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28179
713