1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00

Export to PDF related improvements

This commit is contained in:
Harvey Kandola 2018-06-11 14:40:21 +01:00
parent 2e9734e73e
commit ad2e653f3c
5 changed files with 701 additions and 690 deletions

View file

@ -25,11 +25,7 @@ import (
type RequestContext struct {
AllowAnonymousAccess bool
Authenticated bool
Administrator bool
Guest bool
Editor bool
Global bool
Analytics bool
UserID string
OrgID string
OrgName string
@ -41,6 +37,13 @@ type RequestContext struct {
Fullname string
Transaction *sqlx.Tx
AppVersion string
Administrator bool
Analytics bool
Active bool
Editor bool
Global bool
ViewUsers bool
}
//GetAppURL returns full HTTP url for the app

View file

@ -18,8 +18,8 @@ import (
)
// GetSecuredUser contain associated accounts but credentials are wiped.
func GetSecuredUser(ctx domain.RequestContext, s domain.Store, orgID, q string) (u user.User, err error) {
u, err = s.User.Get(ctx, q)
func GetSecuredUser(ctx domain.RequestContext, s domain.Store, orgID, id string) (u user.User, err error) {
u, err = s.User.Get(ctx, id)
AttachUserAccounts(ctx, s, orgID, &u)
return

File diff suppressed because one or more lines are too long

View file

@ -11,8 +11,8 @@
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import AjaxService from 'ember-ajax/services/ajax';
import config from '../config/environment';
import AjaxService from 'ember-ajax/services/ajax';
export default AjaxService.extend({
session: service(),
@ -44,7 +44,7 @@ export default AjaxService.extend({
window.location.href = 'auth/login';
}
if (is.not.empty(userUpdate)) {
if (this.get('session.authenticated') && is.not.empty(userUpdate) && is.not.undefined(userUpdate)) {
let latest = JSON.parse(userUpdate);
if (!latest.active || user.editor !== latest.editor || user.admin !== latest.admin || user.analytics !== latest.analytics || user.viewUsers !== latest.viewUsers) {
@ -52,7 +52,9 @@ export default AjaxService.extend({
window.location.href = 'auth/login';
}
}
} catch(e){} // eslint-disable-line no-empty
} catch(e) {
console.log(e); // eslint-disable-line no-console
} // eslint-disable-line no-empty
return this._super(...arguments);
}

View file

@ -138,10 +138,12 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
rc.AllowAnonymousAccess = org.AllowAnonymousAccess
rc.OrgName = org.Title
rc.Active = false
rc.Administrator = false
rc.Analytics = false
rc.Editor = false
rc.Global = false
rc.Analytics = false
rc.ViewUsers = false
rc.AppURL = r.Host
rc.Subdomain = organization.GetSubdomainFromHost(r)
rc.SSL = r.TLS != nil
@ -169,9 +171,11 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
}
rc.Administrator = u.Admin
rc.Active = u.Active
rc.Analytics = u.Analytics
rc.Editor = u.Editor
rc.Global = u.Global
rc.Analytics = u.Analytics
rc.ViewUsers = u.ViewUsers
rc.Fullname = u.Fullname()
// We send back with every HTTP request/response cycle the latest
@ -195,7 +199,9 @@ func (m *middleware) Authorize(w http.ResponseWriter, r *http.Request, next http
w.Header().Add("X-Documize-Status", string(sb))
}
// Debug context output
// m.Runtime.Log.Info(fmt.Sprintf("%v", rc))
ctx := context.WithValue(r.Context(), domain.DocumizeContextKey, rc)
r = r.WithContext(ctx)