@flink-app/generic-auth-plugin 0.12.1-alpha.0 → 0.12.1-alpha.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.
Files changed (38) hide show
  1. package/.flink/generatedHandlers.ts +1 -1
  2. package/.flink/generatedJobs.ts +1 -1
  3. package/.flink/generatedRepos.ts +1 -1
  4. package/.flink/schemas/schemas.json +2 -4
  5. package/.flink/schemas/schemas.ts +1 -1
  6. package/.flink/start.ts +1 -1
  7. package/dist/.flink/generatedHandlers.js +1 -1
  8. package/dist/.flink/generatedJobs.js +1 -1
  9. package/dist/.flink/generatedRepos.js +1 -1
  10. package/dist/.flink/schemas/schemas.json +2 -4
  11. package/dist/.flink/start.js +1 -1
  12. package/dist/src/coreFunctions.js +8 -8
  13. package/dist/src/handlers/Management/DeleteUserByUserid.js +21 -23
  14. package/dist/src/handlers/Management/GetSchema.js +12 -14
  15. package/dist/src/handlers/Management/GetUser.js +21 -23
  16. package/dist/src/handlers/Management/GetUserByUserid.js +22 -24
  17. package/dist/src/handlers/Management/GetUserViewByUserid.js +34 -36
  18. package/dist/src/handlers/Management/PutUserPasswordByUserid.js +46 -48
  19. package/dist/src/handlers/Management/PutUserProfileByUserid.js +24 -26
  20. package/dist/src/handlers/Management/PutUserProfileByUseridAppend.js +27 -29
  21. package/dist/src/handlers/Management/PutUserRolesByUserid.js +24 -26
  22. package/dist/src/handlers/Management/PutUserUsernameByUserid.js +33 -35
  23. package/dist/src/handlers/UserCreate.js +44 -46
  24. package/dist/src/handlers/UserLogin.js +23 -25
  25. package/dist/src/handlers/UserLoginByToken.js +23 -25
  26. package/dist/src/handlers/UserPasswordPut.js +21 -23
  27. package/dist/src/handlers/UserPasswordResetComplete.js +27 -29
  28. package/dist/src/handlers/UserPasswordResetForm.js +11 -11
  29. package/dist/src/handlers/UserPasswordResetStart.js +53 -55
  30. package/dist/src/handlers/UserProfileGet.js +21 -23
  31. package/dist/src/handlers/UserProfilePut.js +28 -30
  32. package/dist/src/handlers/UserPushRegisterToken.js +72 -74
  33. package/dist/src/handlers/UserPushRemoveToken.js +25 -27
  34. package/dist/src/handlers/UserToken.js +24 -26
  35. package/dist/src/index.js +7 -8
  36. package/dist/src/init.js +8 -4
  37. package/dist/src/management.js +5 -1
  38. package/package.json +32 -32
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var PutManagementUserProfileByUserid = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, user;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, repo.getById(req.params.userid)];
51
- case 1:
52
- user = _b.sent();
53
- if (user == null) {
54
- return [2 /*return*/, flink_1.notFound()];
55
- }
56
- return [4 /*yield*/, repo.updateOne(user._id, { profile: req.body })];
57
- case 2:
58
- _b.sent();
59
- return [2 /*return*/, {
60
- data: {},
61
- status: 200,
62
- }];
63
- }
64
- });
41
+ var PutManagementUserProfileByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, user;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, repo.getById(req.params.userid)];
50
+ case 1:
51
+ user = _c.sent();
52
+ if (user == null) {
53
+ return [2 /*return*/, (0, flink_1.notFound)()];
54
+ }
55
+ return [4 /*yield*/, repo.updateOne(user._id, { profile: req.body })];
56
+ case 2:
57
+ _c.sent();
58
+ return [2 /*return*/, {
59
+ data: {},
60
+ status: 200,
61
+ }];
62
+ }
65
63
  });
66
- };
64
+ }); };
67
65
  exports.default = PutManagementUserProfileByUserid;
68
66
  exports.__assumedHttpMethod = "put", exports.__file = "PutUserProfileByUserid.ts", exports.__query = [], exports.__params = [];
69
67
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -49,35 +49,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
51
51
  var flink_1 = require("@flink-app/flink");
52
- var PutManagementUserProfileByUserid = function (_a) {
53
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
54
- return __awaiter(void 0, void 0, void 0, function () {
55
- var pluginName, repo, user, profile;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0:
59
- pluginName = origin || "genericAuthPlugin";
60
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
61
- return [4 /*yield*/, repo.getById(req.params.userid)];
62
- case 1:
63
- user = _b.sent();
64
- if (user == null) {
65
- return [2 /*return*/, flink_1.notFound()];
66
- }
67
- if (user.profile == null)
68
- user.profile = {};
69
- profile = __assign(__assign({}, user.profile), req.body);
70
- return [4 /*yield*/, repo.updateOne(user._id, { profile: profile })];
71
- case 2:
72
- _b.sent();
73
- return [2 /*return*/, {
74
- data: {},
75
- status: 200,
76
- }];
77
- }
78
- });
52
+ var PutManagementUserProfileByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
53
+ var pluginName, repo, user, profile;
54
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
55
+ return __generator(this, function (_c) {
56
+ switch (_c.label) {
57
+ case 0:
58
+ pluginName = origin || "genericAuthPlugin";
59
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
60
+ return [4 /*yield*/, repo.getById(req.params.userid)];
61
+ case 1:
62
+ user = _c.sent();
63
+ if (user == null) {
64
+ return [2 /*return*/, (0, flink_1.notFound)()];
65
+ }
66
+ if (user.profile == null)
67
+ user.profile = {};
68
+ profile = __assign(__assign({}, user.profile), req.body);
69
+ return [4 /*yield*/, repo.updateOne(user._id, { profile: profile })];
70
+ case 2:
71
+ _c.sent();
72
+ return [2 /*return*/, {
73
+ data: {},
74
+ status: 200,
75
+ }];
76
+ }
79
77
  });
80
- };
78
+ }); };
81
79
  exports.default = PutManagementUserProfileByUserid;
82
80
  exports.__assumedHttpMethod = "put", exports.__file = "PutUserProfileByUseridAppend.ts", exports.__query = [], exports.__params = [];
83
81
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var PutManagementUserRolesByUserid = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, user;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, repo.getById(req.params.userid)];
51
- case 1:
52
- user = _b.sent();
53
- if (user == null) {
54
- return [2 /*return*/, flink_1.notFound()];
55
- }
56
- return [4 /*yield*/, repo.updateOne(user._id, { roles: req.body.roles })];
57
- case 2:
58
- _b.sent();
59
- return [2 /*return*/, {
60
- data: {},
61
- status: 200,
62
- }];
63
- }
64
- });
41
+ var PutManagementUserRolesByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, user;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, repo.getById(req.params.userid)];
50
+ case 1:
51
+ user = _c.sent();
52
+ if (user == null) {
53
+ return [2 /*return*/, (0, flink_1.notFound)()];
54
+ }
55
+ return [4 /*yield*/, repo.updateOne(user._id, { roles: req.body.roles })];
56
+ case 2:
57
+ _c.sent();
58
+ return [2 /*return*/, {
59
+ data: {},
60
+ status: 200,
61
+ }];
62
+ }
65
63
  });
66
- };
64
+ }); };
67
65
  exports.default = PutManagementUserRolesByUserid;
68
66
  exports.__assumedHttpMethod = "put", exports.__file = "PutUserRolesByUserid.ts", exports.__query = [], exports.__params = [];
69
67
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "roles": { "type": "array", "items": { "type": "string" } } }, "required": ["roles"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,42 +38,40 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var PutManagementUserUsernameByUserid = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, user, existingUser;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, repo.getById(req.params.userid)];
51
- case 1:
52
- user = _b.sent();
53
- if (user == null) {
54
- return [2 /*return*/, flink_1.notFound()];
41
+ var PutManagementUserUsernameByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, user, existingUser;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, repo.getById(req.params.userid)];
50
+ case 1:
51
+ user = _c.sent();
52
+ if (user == null) {
53
+ return [2 /*return*/, (0, flink_1.notFound)()];
54
+ }
55
+ return [4 /*yield*/, repo.getOne({
56
+ username: req.body.username.toLowerCase(),
57
+ })];
58
+ case 2:
59
+ existingUser = _c.sent();
60
+ if (existingUser != null) {
61
+ if (existingUser._id + "" != user._id + "") {
62
+ return [2 /*return*/, (0, flink_1.conflict)("Username already taken")];
55
63
  }
56
- return [4 /*yield*/, repo.getOne({
57
- username: req.body.username.toLowerCase(),
58
- })];
59
- case 2:
60
- existingUser = _b.sent();
61
- if (existingUser != null) {
62
- if (existingUser._id + "" != user._id + "") {
63
- return [2 /*return*/, flink_1.conflict("Username already taken")];
64
- }
65
- }
66
- return [4 /*yield*/, repo.updateOne(user._id, { username: req.body.username.toLowerCase() })];
67
- case 3:
68
- _b.sent();
69
- return [2 /*return*/, {
70
- data: {},
71
- status: 200,
72
- }];
73
- }
74
- });
64
+ }
65
+ return [4 /*yield*/, repo.updateOne(user._id, { username: req.body.username.toLowerCase() })];
66
+ case 3:
67
+ _c.sent();
68
+ return [2 /*return*/, {
69
+ data: {},
70
+ status: 200,
71
+ }];
72
+ }
75
73
  });
76
- };
74
+ }); };
77
75
  exports.default = PutManagementUserUsernameByUserid;
78
76
  exports.__assumedHttpMethod = "put", exports.__file = "PutUserUsernameByUserid.ts", exports.__query = [], exports.__params = [];
79
77
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" } }, "required": ["username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,53 +38,51 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var userCreateHandler = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var _b, password, username, authentificationMethod, profile, roles, pluginName, repo, re, createUserResponse;
45
- return __generator(this, function (_c) {
46
- switch (_c.label) {
47
- case 0:
48
- _b = req.body, password = _b.password, username = _b.username, authentificationMethod = _b.authentificationMethod, profile = _b.profile;
49
- if (authentificationMethod == null) {
50
- authentificationMethod = "password";
41
+ var userCreateHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var _c, password, username, authentificationMethod, profile, roles, pluginName, repo, re, createUserResponse;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_d) {
45
+ switch (_d.label) {
46
+ case 0:
47
+ _c = req.body, password = _c.password, username = _c.username, authentificationMethod = _c.authentificationMethod, profile = _c.profile;
48
+ if (authentificationMethod == null) {
49
+ authentificationMethod = "password";
50
+ }
51
+ if (authentificationMethod == "password" && password == null) {
52
+ return [2 /*return*/, (0, flink_1.internalServerError)("When using password as authentification method password must be supplied")];
53
+ }
54
+ if (password == null) {
55
+ password = "";
56
+ }
57
+ roles = [];
58
+ if (profile == null)
59
+ profile = {};
60
+ pluginName = origin || "genericAuthPlugin";
61
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
62
+ re = ctx.plugins[pluginName].usernameFormat;
63
+ if (!re.test(username)) {
64
+ return [2 /*return*/, (0, flink_1.badRequest)("Username does not meet requirements", "usernameError")];
65
+ }
66
+ return [4 /*yield*/, ctx.plugins.genericAuthPlugin.createUser(repo, ctx.auth, username.toLocaleLowerCase(), password, authentificationMethod, roles, profile, ctx.plugins[pluginName].createPasswordHashAndSaltMethod, ctx.plugins[pluginName].onUserCreated)];
67
+ case 1:
68
+ createUserResponse = _d.sent();
69
+ if (createUserResponse.status != "success") {
70
+ switch (createUserResponse.status) {
71
+ case "error":
72
+ return [2 /*return*/, (0, flink_1.internalServerError)("Unknown error", createUserResponse.status)];
73
+ case "passwordError":
74
+ return [2 /*return*/, (0, flink_1.badRequest)("Invalid password", createUserResponse.status)];
75
+ case "userExists":
76
+ return [2 /*return*/, (0, flink_1.conflict)("User already exists", createUserResponse.status)];
51
77
  }
52
- if (authentificationMethod == "password" && password == null) {
53
- return [2 /*return*/, flink_1.internalServerError("When using password as authentification method password must be supplied")];
54
- }
55
- if (password == null) {
56
- password = "";
57
- }
58
- roles = [];
59
- if (profile == null)
60
- profile = {};
61
- pluginName = origin || "genericAuthPlugin";
62
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
63
- re = ctx.plugins[pluginName].usernameFormat;
64
- if (!re.test(username)) {
65
- return [2 /*return*/, flink_1.badRequest("Username does not meet requirements", "usernameError")];
66
- }
67
- return [4 /*yield*/, ctx.plugins.genericAuthPlugin.createUser(repo, ctx.auth, username.toLocaleLowerCase(), password, authentificationMethod, roles, profile, ctx.plugins[pluginName].createPasswordHashAndSaltMethod, ctx.plugins[pluginName].onUserCreated)];
68
- case 1:
69
- createUserResponse = _c.sent();
70
- if (createUserResponse.status != "success") {
71
- switch (createUserResponse.status) {
72
- case "error":
73
- return [2 /*return*/, flink_1.internalServerError("Unknown error", createUserResponse.status)];
74
- case "passwordError":
75
- return [2 /*return*/, flink_1.badRequest("Invalid password", createUserResponse.status)];
76
- case "userExists":
77
- return [2 /*return*/, flink_1.conflict("User already exists", createUserResponse.status)];
78
- }
79
- }
80
- return [2 /*return*/, {
81
- data: createUserResponse,
82
- status: 200,
83
- }];
84
- }
85
- });
78
+ }
79
+ return [2 /*return*/, {
80
+ data: createUserResponse,
81
+ status: 200,
82
+ }];
83
+ }
86
84
  });
87
- };
85
+ }); };
88
86
  exports.default = userCreateHandler;
89
87
  exports.__assumedHttpMethod = "", exports.__file = "UserCreate.ts", exports.__query = [], exports.__params = [];
90
88
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" }, "authentificationMethod": { "type": "string", "enum": ["password", "sms"] }, "profile": { "type": "object" } }, "required": ["username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "error", "userExists", "passwordError"] }, "user": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "token": { "type": "string" } }, "required": ["_id", "username", "token"], "additionalProperties": false } }, "required": ["status"], "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var userLoginHandler = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, loginRespons;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginUser(repo, ctx.auth, req.body.username, req.body.password, ctx.plugins.genericAuthPlugin.validatePasswordMethod, ctx.plugins[pluginName].smsOptions, ctx.plugins[pluginName].onSuccessfulLogin)];
51
- case 1:
52
- loginRespons = _b.sent();
53
- if (loginRespons.status != "success") {
54
- switch (loginRespons.status) {
55
- case "failed":
56
- return [2 /*return*/, flink_1.unauthorized("Invalid username or password", loginRespons.status)];
57
- }
41
+ var userLoginHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, loginRespons;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginUser(repo, ctx.auth, req.body.username, req.body.password, ctx.plugins.genericAuthPlugin.validatePasswordMethod, ctx.plugins[pluginName].smsOptions, ctx.plugins[pluginName].onSuccessfulLogin)];
50
+ case 1:
51
+ loginRespons = _c.sent();
52
+ if (loginRespons.status != "success") {
53
+ switch (loginRespons.status) {
54
+ case "failed":
55
+ return [2 /*return*/, (0, flink_1.unauthorized)("Invalid username or password", loginRespons.status)];
58
56
  }
59
- return [2 /*return*/, {
60
- data: loginRespons,
61
- status: 200,
62
- }];
63
- }
64
- });
57
+ }
58
+ return [2 /*return*/, {
59
+ data: loginRespons,
60
+ status: 200,
61
+ }];
62
+ }
65
63
  });
66
- };
64
+ }); };
67
65
  exports.default = userLoginHandler;
68
66
  exports.__assumedHttpMethod = "", exports.__file = "UserLogin.ts", exports.__query = [], exports.__params = [];
69
67
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed", "requiresValidation"] }, "user": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "token": { "type": "string" }, "profile": { "type": "object" } }, "required": ["_id", "username", "token", "profile"], "additionalProperties": false }, "validationToken": { "type": "string" } }, "required": ["status"], "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var userLoginHandler = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, loginRespons;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginByToken(repo, ctx.auth, req.body.token, req.body.code, ctx.plugins[pluginName].smsOptions.jwtToken)];
51
- case 1:
52
- loginRespons = _b.sent();
53
- if (loginRespons.status != "success") {
54
- switch (loginRespons.status) {
55
- case "failed":
56
- return [2 /*return*/, flink_1.unauthorized("Invalid token or code", loginRespons.status)];
57
- }
41
+ var userLoginHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, loginRespons;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginByToken(repo, ctx.auth, req.body.token, req.body.code, ctx.plugins[pluginName].smsOptions.jwtToken)];
50
+ case 1:
51
+ loginRespons = _c.sent();
52
+ if (loginRespons.status != "success") {
53
+ switch (loginRespons.status) {
54
+ case "failed":
55
+ return [2 /*return*/, (0, flink_1.unauthorized)("Invalid token or code", loginRespons.status)];
58
56
  }
59
- return [2 /*return*/, {
60
- data: loginRespons,
61
- status: 200,
62
- }];
63
- }
64
- });
57
+ }
58
+ return [2 /*return*/, {
59
+ data: loginRespons,
60
+ status: 200,
61
+ }];
62
+ }
65
63
  });
66
- };
64
+ }); };
67
65
  exports.default = userLoginHandler;
68
66
  exports.__assumedHttpMethod = "", exports.__file = "UserLoginByToken.ts", exports.__query = [], exports.__params = [];
69
67
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "token": { "type": "string" }, "code": { "type": "string" } }, "required": ["code", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed", "requiresValidation"] }, "user": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "token": { "type": "string" }, "profile": { "type": "object" } }, "required": ["_id", "username", "token", "profile"], "additionalProperties": false }, "validationToken": { "type": "string" } }, "required": ["status"], "definitions": {} } };
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,29 +38,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
- var putUserPasswordHandler = function (_a) {
42
- var ctx = _a.ctx, req = _a.req, origin = _a.origin;
43
- return __awaiter(void 0, void 0, void 0, function () {
44
- var pluginName, repo, resp;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- pluginName = origin || "genericAuthPlugin";
49
- repo = ctx.repos[ctx.plugins[pluginName].repoName];
50
- return [4 /*yield*/, ctx.plugins.genericAuthPlugin.changePassword(repo, ctx.auth, req.user._id, req.body.password, ctx.plugins.genericAuthPlugin.createPasswordHashAndSaltMethod)];
51
- case 1:
52
- resp = _b.sent();
53
- switch (resp.status) {
54
- case "failed":
55
- return [2 /*return*/, flink_1.badRequest("Password could not be changed on this user", resp.status)];
56
- case "passwordError":
57
- return [2 /*return*/, flink_1.badRequest("Invalid password", resp.status)];
58
- }
59
- return [2 /*return*/, { data: resp, status: 200 }];
60
- }
61
- });
41
+ var putUserPasswordHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var pluginName, repo, resp;
43
+ var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
+ return __generator(this, function (_c) {
45
+ switch (_c.label) {
46
+ case 0:
47
+ pluginName = origin || "genericAuthPlugin";
48
+ repo = ctx.repos[ctx.plugins[pluginName].repoName];
49
+ return [4 /*yield*/, ctx.plugins.genericAuthPlugin.changePassword(repo, ctx.auth, req.user._id, req.body.password, ctx.plugins.genericAuthPlugin.createPasswordHashAndSaltMethod)];
50
+ case 1:
51
+ resp = _c.sent();
52
+ switch (resp.status) {
53
+ case "failed":
54
+ return [2 /*return*/, (0, flink_1.badRequest)("Password could not be changed on this user", resp.status)];
55
+ case "passwordError":
56
+ return [2 /*return*/, (0, flink_1.badRequest)("Invalid password", resp.status)];
57
+ }
58
+ return [2 /*return*/, { data: resp, status: 200 }];
59
+ }
62
60
  });
63
- };
61
+ }); };
64
62
  exports.default = putUserPasswordHandler;
65
63
  exports.__assumedHttpMethod = "", exports.__file = "UserPasswordPut.ts", exports.__query = [], exports.__params = [];
66
64
  exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "password": { "type": "string" } }, "required": ["password"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed", "passwordError"] } }, "required": ["status"], "definitions": {} } };