mango-cms 0.2.45 → 0.2.47
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/cli.js
CHANGED
|
@@ -168,6 +168,13 @@ program
|
|
|
168
168
|
fs.mkdirSync(projectDir);
|
|
169
169
|
fs.copySync(templateDir, projectDir, { filter: (src, dest) => true });
|
|
170
170
|
|
|
171
|
+
// Copy gitignore file (npm excludes .gitignore, so we store it as gitignore)
|
|
172
|
+
const gitignoreSource = path.join(templateDir, 'gitignore');
|
|
173
|
+
const gitignoreDest = path.join(projectDir, '.gitignore');
|
|
174
|
+
if (fs.existsSync(gitignoreSource)) {
|
|
175
|
+
fs.copySync(gitignoreSource, gitignoreDest);
|
|
176
|
+
}
|
|
177
|
+
|
|
171
178
|
// Create config directory if it doesn't exist
|
|
172
179
|
const configDir = path.join(projectDir, 'mango');
|
|
173
180
|
|
|
@@ -4,7 +4,7 @@ let { PlainText, Select, Timestamp, Relationship } = fields
|
|
|
4
4
|
export default {
|
|
5
5
|
|
|
6
6
|
// title: PlainText({ required: true }),
|
|
7
|
-
author: Relationship({ collection: 'member', single: true,
|
|
7
|
+
author: Relationship({ collection: 'member', single: true, default: (doc, req) => req?.member?.id || null }),
|
|
8
8
|
editId: { computed: (doc, req) => req?.member?.id || null },
|
|
9
9
|
created: { computed: doc => doc.created || new Date, type: 'Float' },
|
|
10
10
|
updated: { computed: doc => doc.updated ? new Date : doc.created, type: 'Float' },
|
package/default/package.json
CHANGED
|
@@ -87,6 +87,14 @@ const processFields = (fields, collectionName) => {
|
|
|
87
87
|
return result
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// Function for setting cookies
|
|
91
|
+
let setCookie = function (cname, cvalue) {
|
|
92
|
+
var d = new Date();
|
|
93
|
+
d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000));
|
|
94
|
+
var expires = "expires=" + d.toUTCString();
|
|
95
|
+
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
const Mango = collections.reduce((a, c) => {
|
|
91
99
|
let localDB = new LocalDB(c.name, api)
|
|
92
100
|
|
|
@@ -487,12 +495,22 @@ Mango.login = ({ email, password }) => {
|
|
|
487
495
|
window.localStorage.setItem('token', response.data.token)
|
|
488
496
|
window.localStorage.setItem('user', response.data.memberId)
|
|
489
497
|
window.localStorage.setItem('email', email)
|
|
498
|
+
setCookie(`Authorization`, `${response.data.token}`)
|
|
490
499
|
resolve(response.data)
|
|
491
500
|
})
|
|
492
501
|
.catch((e) => reject(e))
|
|
493
502
|
})
|
|
494
503
|
}
|
|
495
504
|
|
|
505
|
+
Mango.logout = (axios) => {
|
|
506
|
+
window.localStorage.removeItem('token')
|
|
507
|
+
window.localStorage.removeItem('user')
|
|
508
|
+
window.localStorage.removeItem('email')
|
|
509
|
+
setCookie(`Authorization`, ``)
|
|
510
|
+
if (axios) delete axios.defaults.headers.common['Authorization']
|
|
511
|
+
return true
|
|
512
|
+
}
|
|
513
|
+
|
|
496
514
|
// Build endpoints from the generated .endpoints.json
|
|
497
515
|
Mango.endpoints = Object.keys(endpointsData).reduce((acc, path) => {
|
|
498
516
|
const methods = endpointsData[path]
|
package/default/vite.config.js
CHANGED