notherbase-fs 3.0.10 → 3.1.1
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/README.md +3 -1
- package/controllers/creation.js +29 -5
- package/controllers/spirit-world.js +6 -9
- package/controllers/spirits/user.js +37 -21
- package/models/spirit.js +2 -2
- package/models/user.js +2 -4
- package/package.json +1 -1
- package/public/styles/menu.css +1 -0
- package/test/coast/tall-beach/nono-cove/nono-og/add-gold.js +16 -0
- package/test/coast/tall-beach/nono-cove/nono-og/index.ejs +4 -0
- package/test/coast/tall-beach/nono-cove/nono-og/nono.js +1 -1
- package/test/the-front/add-gold.js +4 -16
- package/views/explorer.ejs +2 -0
- package/views/menu/more.ejs +0 -3
- package/views/scripts/base.js +34 -48
- package/controllers/spirits/contact.js +0 -23
package/README.md
CHANGED
package/controllers/creation.js
CHANGED
|
@@ -29,29 +29,42 @@ export default class Creation {
|
|
|
29
29
|
|
|
30
30
|
explore = async (req, res, next) => {
|
|
31
31
|
let main = `${req.contentPath}`;
|
|
32
|
+
let route = "";
|
|
32
33
|
let siteTitle = `NotherBase - `;
|
|
33
34
|
|
|
34
35
|
if (req.params.frontDetail) {
|
|
35
|
-
|
|
36
|
+
route = `/the-front/${req.params.frontDetail}/index`;
|
|
36
37
|
siteTitle += req.params.frontDetail;
|
|
37
38
|
}
|
|
38
39
|
else if (req.params.detail) {
|
|
39
|
-
|
|
40
|
+
route = `/${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}/index`;
|
|
40
41
|
siteTitle += req.params.detail;
|
|
41
42
|
}
|
|
42
43
|
else if (req.params.poi) {
|
|
43
|
-
|
|
44
|
+
route = `/${req.params.region}/${req.params.area}/${req.params.poi}/index`;
|
|
44
45
|
siteTitle += req.params.poi;
|
|
45
46
|
}
|
|
46
47
|
else {
|
|
47
|
-
|
|
48
|
+
route = `/the-front/index`;
|
|
48
49
|
siteTitle += "the-front";
|
|
49
50
|
}
|
|
51
|
+
main += route;
|
|
50
52
|
|
|
51
53
|
try {
|
|
52
54
|
if (fs.existsSync(main + ".ejs")) {
|
|
53
55
|
let user = await req.db.User.recallOne(req.session.currentUser);
|
|
54
56
|
|
|
57
|
+
let stats = await req.db.Spirit.recallOne("stats");
|
|
58
|
+
if (stats.memory.data[route]) {
|
|
59
|
+
stats.memory.data[route].visits++;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
stats.memory.data[route] = {
|
|
63
|
+
visits: 1
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
await stats.commit();
|
|
67
|
+
|
|
55
68
|
let userStuff = {
|
|
56
69
|
userID: null,
|
|
57
70
|
user: null,
|
|
@@ -67,7 +80,7 @@ export default class Creation {
|
|
|
67
80
|
siteTitle: siteTitle,
|
|
68
81
|
main: main,
|
|
69
82
|
query: req.query,
|
|
70
|
-
dir: req.frontDir,
|
|
83
|
+
// dir: req.frontDir,
|
|
71
84
|
route: req.path,
|
|
72
85
|
requireUser: req.lock
|
|
73
86
|
}
|
|
@@ -91,6 +104,17 @@ export default class Creation {
|
|
|
91
104
|
if (fs.existsSync(main)) {
|
|
92
105
|
let user = await req.db.User.recallOne(req.session.currentUser);
|
|
93
106
|
|
|
107
|
+
let stats = await req.db.Spirit.recallOne("stats");
|
|
108
|
+
if (stats.memory.data[main]) {
|
|
109
|
+
stats.memory.data[main].visits++;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
stats.memory.data[main] = {
|
|
113
|
+
visits: 1
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
await stats.commit();
|
|
117
|
+
|
|
94
118
|
let userStuff = {
|
|
95
119
|
userID: null,
|
|
96
120
|
user: null
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
import { stripHtml } from "string-strip-html";
|
|
3
|
-
import User from "./spirits/user.js";
|
|
4
|
-
import Contact from "./spirits/contact.js";
|
|
5
3
|
import { success, fail } from "./spirits/util.js";
|
|
4
|
+
import User from "./spirits/user.js";
|
|
6
5
|
import fs from 'fs';
|
|
7
6
|
|
|
8
7
|
export default class SpiritWorld {
|
|
@@ -36,12 +35,10 @@ export default class SpiritWorld {
|
|
|
36
35
|
this.io = io;
|
|
37
36
|
this.router = express.Router();
|
|
38
37
|
this.user = new User();
|
|
39
|
-
this.contact = new Contact();
|
|
40
38
|
|
|
39
|
+
this.router.post("/load", this.load);
|
|
41
40
|
this.router.post("/serve", this.serve);
|
|
42
|
-
this.router.get("/load", this.load);
|
|
43
41
|
this.router.use("/user", this.user.router);
|
|
44
|
-
this.router.use("/contact-nother", this.contact.router);
|
|
45
42
|
|
|
46
43
|
this.io.on('connection', this.#setupChat);
|
|
47
44
|
}
|
|
@@ -49,12 +46,12 @@ export default class SpiritWorld {
|
|
|
49
46
|
load = async (req, res) => {
|
|
50
47
|
let parent = null;
|
|
51
48
|
|
|
52
|
-
if (req.
|
|
49
|
+
if (req.body.scope === "local") {
|
|
53
50
|
let user = await req.db.User.recallOne(req.session.currentUser);
|
|
54
51
|
parent = user.id;
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
let spirit = await req.db.Spirit.recallOne(req.
|
|
54
|
+
let spirit = await req.db.Spirit.recallOne(req.body.service, parent);
|
|
58
55
|
|
|
59
56
|
if (!spirit.memory.data) spirit.memory.data = {};
|
|
60
57
|
|
|
@@ -63,7 +60,7 @@ export default class SpiritWorld {
|
|
|
63
60
|
|
|
64
61
|
serve = async (req, res) => {
|
|
65
62
|
try {
|
|
66
|
-
let scriptPath = `${req.contentPath}${req.body.
|
|
63
|
+
let scriptPath = `${req.contentPath}${req.body.route}/${req.body.script}.js`;
|
|
67
64
|
|
|
68
65
|
let script, result = null;
|
|
69
66
|
|
|
@@ -74,7 +71,7 @@ export default class SpiritWorld {
|
|
|
74
71
|
result = await script.default(req, user);
|
|
75
72
|
success(res, "Served.", result);
|
|
76
73
|
}
|
|
77
|
-
else fail(res, `Script not found: ${req.body.
|
|
74
|
+
else fail(res, `Script not found: ${req.body.script} at ${scriptPath}`);
|
|
78
75
|
} catch (error) {
|
|
79
76
|
console.log(error);
|
|
80
77
|
fail(res, "Server error");
|
|
@@ -16,6 +16,7 @@ export default class User {
|
|
|
16
16
|
this.router.post("/deletePermanently", this.deletePermanently);
|
|
17
17
|
this.router.post("/getInventory", this.getInventory);
|
|
18
18
|
this.router.post("/getAttributes", this.getAttributes);
|
|
19
|
+
this.router.post("/getInfo", this.getInfo);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
logout = async (req, res) => {
|
|
@@ -25,18 +26,18 @@ export default class User {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
sendPasswordReset = async (req, res) => {
|
|
28
|
-
let spirit = await req.db.User.recallOne(req.body.
|
|
29
|
+
let spirit = await req.db.User.recallOne(req.body.email);
|
|
29
30
|
|
|
30
31
|
if (spirit) {
|
|
31
32
|
let token = Math.floor(Math.random() * 9999);
|
|
32
33
|
|
|
33
|
-
if (req.body.
|
|
34
|
+
if (req.body.test) console.log("token: " + token);
|
|
34
35
|
|
|
35
36
|
spirit.memory.data.resetToken = token;
|
|
36
37
|
spirit.memory.data.resetExp = Date.now() + (1000 * 60 * 10);
|
|
37
38
|
await spirit.commit();
|
|
38
39
|
|
|
39
|
-
req.db.SendMail.passwordReset(req.body.
|
|
40
|
+
req.db.SendMail.passwordReset(req.body.email, token);
|
|
40
41
|
|
|
41
42
|
success(res, "Password reset token sent.");
|
|
42
43
|
}
|
|
@@ -44,18 +45,18 @@ export default class User {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
changePassword = async (req, res) => {
|
|
47
|
-
if (check(res, req.body.
|
|
48
|
-
let spirit = await req.db.User.recallOne(req.body.
|
|
48
|
+
if (check(res, req.body.token, "No token provided!")){
|
|
49
|
+
let spirit = await req.db.User.recallOne(req.body.email);
|
|
49
50
|
|
|
50
51
|
if (check(res, spirit, "User not found!") &&
|
|
51
|
-
check(res, spirit.memory.data.resetToken == req.body.
|
|
52
|
+
check(res, spirit.memory.data.resetToken == req.body.token, "Reset token not valid!") &&
|
|
52
53
|
check(res, spirit.memory.data.resetExp > Date.now(), "Reset token expired!") &&
|
|
53
|
-
check(res, req.body.
|
|
54
|
+
check(res, req.body.password === req.body.confirmation, "Passwords must match!"))
|
|
54
55
|
{
|
|
55
56
|
spirit.memory.data.resetExp = -1;
|
|
56
57
|
|
|
57
58
|
const salt = await bcrypt.genSalt(10);
|
|
58
|
-
const hash = await bcrypt.hash(req.body.
|
|
59
|
+
const hash = await bcrypt.hash(req.body.password, salt);
|
|
59
60
|
|
|
60
61
|
spirit.memory.data.password = hash;
|
|
61
62
|
await spirit.commit();
|
|
@@ -66,14 +67,14 @@ export default class User {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
register = async (req, res) => {
|
|
69
|
-
if (check(res, req.body.
|
|
70
|
-
check(res, req.body.
|
|
71
|
-
check(res, req.body.
|
|
70
|
+
if (check(res, req.body.password.length > 7, "Password too short.") &&
|
|
71
|
+
check(res, req.body.email.length > 7, "Email too short.") &&
|
|
72
|
+
check(res, req.body.username.length > 2, "Username too short."))
|
|
72
73
|
{
|
|
73
|
-
let spirit = await req.db.User.recallOne(req.body.
|
|
74
|
+
let spirit = await req.db.User.recallOne(req.body.email);
|
|
74
75
|
|
|
75
76
|
if (check(res, !spirit, "Email already in use!")) {
|
|
76
|
-
spirit = await req.db.User.create(req.body.
|
|
77
|
+
spirit = await req.db.User.create(req.body.username, req.body.password, req.body.email);
|
|
77
78
|
|
|
78
79
|
success(res, "Registration successful!");
|
|
79
80
|
}
|
|
@@ -81,12 +82,13 @@ export default class User {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
login = async (req, res) => {
|
|
84
|
-
let spirit = await req.db.User.recallOne(req.body.
|
|
85
|
+
let spirit = await req.db.User.recallOne(req.body.email);
|
|
86
|
+
|
|
85
87
|
if (check(res, spirit, "User not found.")) {
|
|
86
|
-
let passResult = await bcrypt.compare(req.body.
|
|
88
|
+
let passResult = await bcrypt.compare(req.body.password, spirit.memory.data.password);
|
|
87
89
|
|
|
88
90
|
if (check(res, passResult, "Password doesn't match the email.")) {
|
|
89
|
-
req.session.currentUser = req.body.
|
|
91
|
+
req.session.currentUser = req.body.email;
|
|
90
92
|
|
|
91
93
|
success(res, "Logged in.", spirit.memory.data.username);
|
|
92
94
|
}
|
|
@@ -95,15 +97,15 @@ export default class User {
|
|
|
95
97
|
|
|
96
98
|
changeEmail = async (req, res) => {
|
|
97
99
|
if (loginCheck(req, res)) {
|
|
98
|
-
let spirit = await req.db.User.recallOne(req.body.
|
|
100
|
+
let spirit = await req.db.User.recallOne(req.body.email);
|
|
99
101
|
|
|
100
102
|
if (check(res, !spirit, "Email already in use!")) {
|
|
101
103
|
spirit = await req.db.User.recallOne(req.session.currentUser);
|
|
102
104
|
|
|
103
|
-
spirit.memory.data.email = req.body.
|
|
105
|
+
spirit.memory.data.email = req.body.email;
|
|
104
106
|
await spirit.commit();
|
|
105
107
|
|
|
106
|
-
req.session.currentUser = req.body.
|
|
108
|
+
req.session.currentUser = req.body.email;
|
|
107
109
|
|
|
108
110
|
success(res, "Email changed.");
|
|
109
111
|
}
|
|
@@ -112,12 +114,12 @@ export default class User {
|
|
|
112
114
|
|
|
113
115
|
changeUsername = async (req, res) => {
|
|
114
116
|
if (loginCheck(req, res)) {
|
|
115
|
-
let spirit = await req.db.User.recallOne(null, req.body.
|
|
117
|
+
let spirit = await req.db.User.recallOne(null, req.body.username);
|
|
116
118
|
|
|
117
119
|
if (check(res, !spirit, "Username already in use!")) {
|
|
118
120
|
spirit = await req.db.User.recallOne(req.session.currentUser);
|
|
119
121
|
|
|
120
|
-
spirit.memory.data.username = req.body.
|
|
122
|
+
spirit.memory.data.username = req.body.username;
|
|
121
123
|
await spirit.commit();
|
|
122
124
|
|
|
123
125
|
success(res, "Username changed");
|
|
@@ -159,4 +161,18 @@ export default class User {
|
|
|
159
161
|
else fail(res, "Attributes up to date.");
|
|
160
162
|
}
|
|
161
163
|
}
|
|
164
|
+
|
|
165
|
+
getInfo = async (req, res) => {
|
|
166
|
+
if (loginCheck(req, res)) {
|
|
167
|
+
let user = await req.db.User.recallOne(req.session.currentUser);
|
|
168
|
+
|
|
169
|
+
if (user.memory._lastUpdate > req.body._lastUpdate) {
|
|
170
|
+
success(res, "Info found", {
|
|
171
|
+
email: user.memory.data.email,
|
|
172
|
+
username: user.memory.data.username
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else fail(res, "Info up to date.");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
}
|
package/models/spirit.js
CHANGED
|
@@ -77,8 +77,8 @@ export default class Spirit {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
static delete = async (
|
|
81
|
-
let found = await Spirit.db.deleteMany(Spirit.buildQuery(
|
|
80
|
+
static delete = async (service, data = {}, id = null) => {
|
|
81
|
+
let found = await Spirit.db.deleteMany(Spirit.buildQuery(service, data, id));
|
|
82
82
|
|
|
83
83
|
return found.deletedCount;
|
|
84
84
|
}
|
package/models/user.js
CHANGED
|
@@ -66,13 +66,11 @@ export default class User extends Spirit {
|
|
|
66
66
|
return spirit;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
static delete = async (
|
|
69
|
+
static delete = async (email) => {
|
|
70
70
|
let found = await Spirit.db.findAndDelete(Spirit.buildQuery({
|
|
71
|
-
route: "/",
|
|
72
71
|
service: "user",
|
|
73
|
-
scope: "global",
|
|
74
72
|
parent: null
|
|
75
|
-
}, { email:
|
|
73
|
+
}, { email: email }));
|
|
76
74
|
|
|
77
75
|
return found.deletedCount;
|
|
78
76
|
}
|
package/package.json
CHANGED
package/public/styles/menu.css
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default async (req, user) => {
|
|
2
|
+
await user.offsetItem("Gold Coin", 3);
|
|
3
|
+
|
|
4
|
+
let spirit = await req.db.Spirit.recallOne("test");
|
|
5
|
+
if (!spirit.memory.data.amount) spirit.memory.data.amount = 0;
|
|
6
|
+
spirit.memory.data.amount += 3;
|
|
7
|
+
await spirit.commit();
|
|
8
|
+
|
|
9
|
+
let stats = await req.db.Spirit.recallOne("stats");
|
|
10
|
+
let render = [];
|
|
11
|
+
let keys = Object.keys(stats.memory.data);
|
|
12
|
+
for (let i = 0; i < keys.length; i++) {
|
|
13
|
+
render.push(`${keys[i]} - ${stats.memory.data[keys[i]].visits}`)
|
|
14
|
+
}
|
|
15
|
+
console.log(render);
|
|
16
|
+
}
|
|
@@ -7,27 +7,15 @@ export default async (req, user) => {
|
|
|
7
7
|
|
|
8
8
|
await user.offsetItem("Gold Coin", 15);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
parent: user.id,
|
|
14
|
-
service: "gold"
|
|
15
|
-
}, {}, {
|
|
16
|
-
gold: 0
|
|
17
|
-
});
|
|
10
|
+
// await req.db.Spirit.delete("gold");
|
|
11
|
+
|
|
12
|
+
let local = await req.db.Spirit.recallOne("gold", user.id);
|
|
18
13
|
|
|
19
14
|
if (!local.memory.data.gold) local.memory.data.gold = 0;
|
|
20
15
|
local.memory.data.gold += 15;
|
|
21
16
|
await local.commit();
|
|
22
17
|
|
|
23
|
-
let global = await req.db.Spirit.
|
|
24
|
-
route: req.body.route,
|
|
25
|
-
scope: "global",
|
|
26
|
-
parent: null,
|
|
27
|
-
service: "gold"
|
|
28
|
-
}, {}, {
|
|
29
|
-
gold: 0
|
|
30
|
-
});
|
|
18
|
+
let global = await req.db.Spirit.recallOne("gold");
|
|
31
19
|
|
|
32
20
|
if (!global.memory.data.gold) global.memory.data.gold = 0;
|
|
33
21
|
global.memory.data.gold += 15;
|
package/views/explorer.ejs
CHANGED
package/views/menu/more.ejs
CHANGED
package/views/scripts/base.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
class Base {
|
|
2
|
-
static commune = async (route, data =
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
let response = null;
|
|
2
|
+
static commune = async (route, data = {}) => {
|
|
3
|
+
let response = await $.post("/s/user/" + route, JSON.stringify(data));
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
response = res;
|
|
9
|
-
if (res.status != "success") console.log(`${route} - ${res.message}`);
|
|
10
|
-
});
|
|
5
|
+
if (response.status != "success") console.log(`${"/s/user/" + route} - ${response.message}`);
|
|
11
6
|
|
|
12
7
|
return response;
|
|
13
8
|
}
|
|
@@ -17,15 +12,13 @@ class Base {
|
|
|
17
12
|
this.items = [];
|
|
18
13
|
this.lastUpdate = 0;
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
this.refresh();
|
|
22
|
-
<% } %>
|
|
15
|
+
this.refresh();
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
async refresh() {
|
|
26
19
|
let $list = $(".inventory .item-list");
|
|
27
20
|
|
|
28
|
-
let response = await Base.commune("
|
|
21
|
+
let response = await Base.commune("getInventory", { _lastUpdate: this.lastUpdate });
|
|
29
22
|
|
|
30
23
|
if (response.status === "success") {
|
|
31
24
|
this.items = response.data;
|
|
@@ -68,13 +61,11 @@ class Base {
|
|
|
68
61
|
this.attributes = [];
|
|
69
62
|
this.lastUpdate = 0;
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
this.refresh();
|
|
73
|
-
<% } %>
|
|
64
|
+
this.refresh();
|
|
74
65
|
}
|
|
75
66
|
|
|
76
67
|
async refresh() {
|
|
77
|
-
let response = await Base.commune("
|
|
68
|
+
let response = await Base.commune("getAttributes", { _lastUpdate: this.lastUpdate });
|
|
78
69
|
if (response.status === "success") {
|
|
79
70
|
this.lastUpdate = response.lastUpdate;
|
|
80
71
|
this.attributes = response.data;
|
|
@@ -100,16 +91,19 @@ class Base {
|
|
|
100
91
|
constructor() {
|
|
101
92
|
this.username = "";
|
|
102
93
|
this.email = "";
|
|
94
|
+
this.lastUpdate = 0;
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
this.username = "<%= user.username %>";
|
|
106
|
-
this.email = "<%= user.email %>";
|
|
107
|
-
|
|
108
|
-
this.refresh();
|
|
109
|
-
<% } %>
|
|
96
|
+
this.refresh();
|
|
110
97
|
}
|
|
111
98
|
|
|
112
|
-
refresh() {
|
|
99
|
+
async refresh() {
|
|
100
|
+
let response = await Base.commune("getInfo", { _lastUpdate: this.lastUpdate });
|
|
101
|
+
if (response.status === "success") {
|
|
102
|
+
this.lastUpdate = response.lastUpdate;
|
|
103
|
+
this.email = response.data.email;
|
|
104
|
+
this.username = response.data.username;
|
|
105
|
+
}
|
|
106
|
+
|
|
113
107
|
let $email = $(".content#account .setting#email p");
|
|
114
108
|
let $emailInput = $(".content#account .edit#email input");
|
|
115
109
|
let $username = $(".content#account .setting#username p");
|
|
@@ -148,9 +142,10 @@ class Base {
|
|
|
148
142
|
let $email = $(".content#account .setting#email p");
|
|
149
143
|
let $emailInput = $(".content#account .edit#email input");
|
|
150
144
|
|
|
151
|
-
let response = await Base.commune("
|
|
145
|
+
let response = await Base.commune("changeEmail", { email: $emailInput.val() });
|
|
152
146
|
|
|
153
147
|
if (response.status === "success") {
|
|
148
|
+
this.email = $emailInput.val();
|
|
154
149
|
$email.text($emailInput.val());
|
|
155
150
|
$info.text("Email Updated.");
|
|
156
151
|
}
|
|
@@ -184,9 +179,10 @@ class Base {
|
|
|
184
179
|
let $username = $(".content#account .setting#username p");
|
|
185
180
|
let $usernameInput = $(".content#account .edit#username input");
|
|
186
181
|
|
|
187
|
-
let response = await Base.commune("
|
|
182
|
+
let response = await Base.commune("changeUsername", { username: $usernameInput.val() });
|
|
188
183
|
|
|
189
184
|
if (response.status === "success") {
|
|
185
|
+
this.username = $usernameInput.val();
|
|
190
186
|
$username.text($usernameInput.val());
|
|
191
187
|
$info.text("Username Updated.");
|
|
192
188
|
}
|
|
@@ -202,6 +198,8 @@ class Base {
|
|
|
202
198
|
this.playerAttributes = new this.#PlayerAttributes();
|
|
203
199
|
this.playerAccount = new this.#AccountServices();
|
|
204
200
|
this.menuClosing = false;
|
|
201
|
+
|
|
202
|
+
this.switchTab("inventory");
|
|
205
203
|
}
|
|
206
204
|
|
|
207
205
|
closeMenu = () => {
|
|
@@ -237,22 +235,13 @@ class Base {
|
|
|
237
235
|
}
|
|
238
236
|
|
|
239
237
|
logout = async () => {
|
|
240
|
-
let response = await Base.commune("
|
|
238
|
+
let response = await Base.commune("logout");
|
|
241
239
|
|
|
242
240
|
return response;
|
|
243
241
|
}
|
|
244
|
-
|
|
245
|
-
sendMessageToNother = async () => {
|
|
246
|
-
await Base.commune("contactNother", {
|
|
247
|
-
content: $(".menu .content#more #content").val(),
|
|
248
|
-
route: currentRoute
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
$(".menu .content#more #content").val("");
|
|
252
|
-
}
|
|
253
242
|
|
|
254
243
|
attemptRegister = async (email, username, password) => {
|
|
255
|
-
let response = await Base.commune("
|
|
244
|
+
let response = await Base.commune("register", {
|
|
256
245
|
email, username, password
|
|
257
246
|
});
|
|
258
247
|
|
|
@@ -260,7 +249,7 @@ class Base {
|
|
|
260
249
|
}
|
|
261
250
|
|
|
262
251
|
attemptLogin = async (email, password) => {
|
|
263
|
-
let response = await Base.commune("
|
|
252
|
+
let response = await Base.commune("login", {
|
|
264
253
|
email: email,
|
|
265
254
|
password: password
|
|
266
255
|
});
|
|
@@ -277,24 +266,25 @@ class Base {
|
|
|
277
266
|
};
|
|
278
267
|
|
|
279
268
|
resetPassword = async (email, test = false) => {
|
|
280
|
-
let response = await Base.commune("
|
|
269
|
+
let response = await Base.commune("sendPasswordReset", { email, test });
|
|
281
270
|
|
|
282
271
|
return response;
|
|
283
272
|
}
|
|
284
273
|
|
|
285
274
|
changePassword = async (token, email, password, confirmation) => {
|
|
286
|
-
let response = await Base.commune("
|
|
275
|
+
let response = await Base.commune("changePassword", { token, email, password, confirmation });
|
|
287
276
|
|
|
288
277
|
return response;
|
|
289
278
|
}
|
|
290
279
|
|
|
291
280
|
do = async (what, data = null) => {
|
|
292
|
-
|
|
293
|
-
let response = await Base.commune("/s/serve", {
|
|
281
|
+
let response = await $.post("/s/serve", JSON.stringify({
|
|
294
282
|
script: what,
|
|
295
283
|
route: window.location.pathname,
|
|
296
284
|
...data
|
|
297
|
-
});
|
|
285
|
+
}));
|
|
286
|
+
|
|
287
|
+
if (response.status != "success") console.log(`${window.location.pathname} - ${response.message}`);
|
|
298
288
|
|
|
299
289
|
this.playerInventory.refresh();
|
|
300
290
|
this.playerAttributes.refresh();
|
|
@@ -303,12 +293,8 @@ class Base {
|
|
|
303
293
|
}
|
|
304
294
|
|
|
305
295
|
load = async (service, scope = "local") => {
|
|
306
|
-
let response = await $.
|
|
296
|
+
let response = await $.post("/s/load", JSON.stringify({ service, scope }));
|
|
307
297
|
|
|
308
298
|
return response;
|
|
309
299
|
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const base = new Base();
|
|
313
|
-
|
|
314
|
-
base.switchTab("inventory");
|
|
300
|
+
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import express from "express";
|
|
2
|
-
import { success } from "./util.js";
|
|
3
|
-
|
|
4
|
-
export default class Contact {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.router = express.Router();
|
|
7
|
-
|
|
8
|
-
this.router.post(`/`, this.contactNother);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
contactNother = async function(req, res) {
|
|
12
|
-
let user = await User.recallOne(req.session.currentUser);
|
|
13
|
-
|
|
14
|
-
let spirit = await req.db.Spirit.create({
|
|
15
|
-
route: "/",
|
|
16
|
-
service: "nother-contacts",
|
|
17
|
-
scope: "local",
|
|
18
|
-
parent: user.id
|
|
19
|
-
}, req.body);
|
|
20
|
-
|
|
21
|
-
success(res, "Message sent.");
|
|
22
|
-
}
|
|
23
|
-
}
|