refs #6930 feat: use tokenMultimedia intead tokenUser
This commit is contained in:
parent
a078de9521
commit
ae0ce8e49a
|
@ -83,7 +83,7 @@ export default class Auth {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginOk(json, now, remember) {
|
onLoginOk(json, now, remember) {
|
||||||
this.vnToken.set(json.data.token, now, json.data.ttl, remember);
|
this.vnToken.set(json.data.token, json.data.multimediaToken.id, now, json.data.ttl, remember);
|
||||||
|
|
||||||
return this.loadAcls().then(() => {
|
return this.loadAcls().then(() => {
|
||||||
let continueHash = this.$state.params.continue;
|
let continueHash = this.$state.params.continue;
|
||||||
|
|
|
@ -24,21 +24,22 @@ export default class Token {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(token, created, ttl, remember) {
|
set(token, tokenMultimedia, created, ttl, remember) {
|
||||||
this.unset();
|
this.unset();
|
||||||
|
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
token,
|
token,
|
||||||
|
tokenMultimedia,
|
||||||
created,
|
created,
|
||||||
ttl,
|
ttl,
|
||||||
remember
|
remember
|
||||||
});
|
});
|
||||||
this.vnInterceptor.setToken(token);
|
this.vnInterceptor.setToken(token, tokenMultimedia);
|
||||||
try {
|
try {
|
||||||
if (remember)
|
if (remember)
|
||||||
this.setStorage(localStorage, token, created, ttl);
|
this.setStorage(localStorage, token, tokenMultimedia, created, ttl);
|
||||||
else
|
else
|
||||||
this.setStorage(sessionStorage, token, created, ttl);
|
this.setStorage(sessionStorage, token, tokenMultimedia, created, ttl);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,7 @@ export default class Token {
|
||||||
|
|
||||||
unset() {
|
unset() {
|
||||||
this.token = null;
|
this.token = null;
|
||||||
|
this.tokenMultimedia = null;
|
||||||
this.created = null;
|
this.created = null;
|
||||||
this.ttl = null;
|
this.ttl = null;
|
||||||
this.remember = null;
|
this.remember = null;
|
||||||
|
@ -57,13 +59,15 @@ export default class Token {
|
||||||
|
|
||||||
getStorage(storage) {
|
getStorage(storage) {
|
||||||
this.token = storage.getItem('vnToken');
|
this.token = storage.getItem('vnToken');
|
||||||
|
this.tokenMultimedia = storage.getItem('vnTokenMultimedia');
|
||||||
if (!this.token) return;
|
if (!this.token) return;
|
||||||
const created = storage.getItem('vnTokenCreated');
|
const created = storage.getItem('vnTokenCreated');
|
||||||
this.created = created && new Date(created);
|
this.created = created && new Date(created);
|
||||||
this.ttl = storage.getItem('vnTokenTtl');
|
this.ttl = storage.getItem('vnTokenTtl');
|
||||||
}
|
}
|
||||||
|
|
||||||
setStorage(storage, token, created, ttl) {
|
setStorage(storage, token, tokenMultimedia, created, ttl) {
|
||||||
|
storage.setItem('vnTokenMultimedia', tokenMultimedia);
|
||||||
storage.setItem('vnToken', token);
|
storage.setItem('vnToken', token);
|
||||||
storage.setItem('vnTokenCreated', created.toJSON());
|
storage.setItem('vnTokenCreated', created.toJSON());
|
||||||
storage.setItem('vnTokenTtl', ttl);
|
storage.setItem('vnTokenTtl', ttl);
|
||||||
|
@ -71,6 +75,7 @@ export default class Token {
|
||||||
|
|
||||||
removeStorage(storage) {
|
removeStorage(storage) {
|
||||||
storage.removeItem('vnToken');
|
storage.removeItem('vnToken');
|
||||||
|
storage.removeItem('vnTokenMultimedia');
|
||||||
storage.removeItem('vnTokenCreated');
|
storage.removeItem('vnTokenCreated');
|
||||||
storage.removeItem('vnTokenTtl');
|
storage.removeItem('vnTokenTtl');
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,7 @@ export class Layout extends Component {
|
||||||
if (!this.$.$root.user) return;
|
if (!this.$.$root.user) return;
|
||||||
|
|
||||||
const userId = this.$.$root.user.id;
|
const userId = this.$.$root.user.id;
|
||||||
const token = this.vnToken.token;
|
return `/api/Images/user/160x160/${userId}/download?access_token=${this.vnToken.tokenMultimedia}`;
|
||||||
return `/api/Images/user/160x160/${userId}/download?access_token=${token}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
ng-click="$ctrl.showDescriptor($event, userLog)">
|
ng-click="$ctrl.showDescriptor($event, userLog)">
|
||||||
<img
|
<img
|
||||||
ng-if="::userLog.user.image"
|
ng-if="::userLog.user.image"
|
||||||
ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.token}}">
|
ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
|
||||||
</img>
|
</img>
|
||||||
</vn-avatar>
|
</vn-avatar>
|
||||||
</div>
|
</div>
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
val="{{::nickname}}">
|
val="{{::nickname}}">
|
||||||
<img
|
<img
|
||||||
ng-if="::image"
|
ng-if="::image"
|
||||||
ng-src="/api/Images/user/160x160/{{::id}}/download?access_token={{::$ctrl.vnToken.token}}">
|
ng-src="/api/Images/user/160x160/{{::id}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
|
||||||
</img>
|
</img>
|
||||||
</vn-avatar>
|
</vn-avatar>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function run($window, $rootScope, vnAuth, vnApp, vnToken, $state) {
|
||||||
if (!collection || !size || !id) return;
|
if (!collection || !size || !id) return;
|
||||||
|
|
||||||
const basePath = `/api/Images/${collection}/${size}/${id}`;
|
const basePath = `/api/Images/${collection}/${size}/${id}`;
|
||||||
return `${basePath}/download?access_token=${vnToken.token}`;
|
return `${basePath}/download?access_token=${vnToken.tokenMultimedia}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
$window.validations = {};
|
$window.validations = {};
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
<vn-td center shrink>
|
<vn-td center shrink>
|
||||||
<a ng-show="balance.hasPdf"
|
<a ng-show="balance.hasPdf"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="api/InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.token}}">
|
href="api/InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.tokenMultimedia}}">
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="cloud_download"
|
icon="cloud_download"
|
||||||
title="{{'Download PDF' | translate}}">
|
title="{{'Download PDF' | translate}}">
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<vn-menu vn-id="showInvoiceMenu">
|
<vn-menu vn-id="showInvoiceMenu">
|
||||||
<vn-list>
|
<vn-list>
|
||||||
<a class="vn-item"
|
<a class="vn-item"
|
||||||
href="api/InvoiceOuts/{{$ctrl.id}}/download?access_token={{$ctrl.vnToken.token}}"
|
href="api/InvoiceOuts/{{$ctrl.id}}/download?access_token={{$ctrl.vnToken.tokenMultimedia}}"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
name="showInvoicePdf"
|
name="showInvoicePdf"
|
||||||
translate>
|
translate>
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default class Controller extends Section {
|
||||||
openPdf() {
|
openPdf() {
|
||||||
if (this.checked.length <= 1) {
|
if (this.checked.length <= 1) {
|
||||||
const [invoiceOutId] = this.checked;
|
const [invoiceOutId] = this.checked;
|
||||||
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.token}`;
|
const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${this.vnToken.tokenMultimedia}`;
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
} else {
|
||||||
const invoiceOutIds = this.checked;
|
const invoiceOutIds = this.checked;
|
||||||
|
|
|
@ -40,7 +40,7 @@ export default class Controller extends Section {
|
||||||
const stringRoutesIds = routesIds.join(',');
|
const stringRoutesIds = routesIds.join(',');
|
||||||
|
|
||||||
if (this.checked.length <= 1) {
|
if (this.checked.length <= 1) {
|
||||||
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`;
|
const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.tokenMultimedia}`;
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
} else {
|
} else {
|
||||||
const serializedParams = this.$httpParamSerializer({
|
const serializedParams = this.$httpParamSerializer({
|
||||||
|
|
Loading…
Reference in New Issue