@saltcorn/mobile-app 1.7.0-beta.0 → 1.7.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saltcorn/mobile-app",
3
3
  "displayName": "Saltcorn mobile app",
4
- "version": "1.7.0-beta.0",
4
+ "version": "1.7.0-beta.2",
5
5
  "description": "Saltcorn mobile app for Android and iOS",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -37,10 +37,7 @@ export const postView = async (context) => {
37
37
  const res = new MobileResponse();
38
38
  const state = saltcorn.data.state.getState();
39
39
  const mobileCfg = state.mobileConfig;
40
- if (
41
- mobileCfg.user.role_id > view.min_role &&
42
- !(await view.authorize(mobileCfg.user, { action: "post", req, body }))
43
- ) {
40
+ if (!(await view.authorize(mobileCfg.user, { action: "post", req, body }))) {
44
41
  throw new saltcorn.data.utils.NotAuthorized(req.__("Not authorized"));
45
42
  }
46
43
  await view.runPost(
@@ -92,7 +89,14 @@ export const postViewRoute = async (context) => {
92
89
  const res = new MobileResponse();
93
90
  const state = saltcorn.data.state.getState();
94
91
  const { user, isOfflineMode } = state.mobileConfig;
95
- if (user.role_id > view.min_role)
92
+ if (
93
+ !(await view.authorize(user, {
94
+ action: "post",
95
+ route: context.params.route,
96
+ req,
97
+ body: context.data || {},
98
+ }))
99
+ )
96
100
  throw new saltcorn.data.utils.NotAuthorized(req.__("Not authorized"));
97
101
 
98
102
  if (!isOfflineMode && view.viewtemplateObj?.name === "WorkflowRoom") {
@@ -149,7 +153,6 @@ export const getView = async (context) => {
149
153
  const view = saltcorn.data.models.View.findOne({ name: viewname });
150
154
  if (!view) throw new Error(req.__("No such view: %s", viewname));
151
155
  if (
152
- state.mobileConfig.user.role_id > view.min_role &&
153
156
  !(await view.authorize(state.mobileConfig.user, {
154
157
  action: "get",
155
158
  req,