|
| 1 | +"use strict"; |
| 2 | +/* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved. |
| 3 | + * |
| 4 | + * This software is licensed under the Apache License, Version 2.0 (the |
| 5 | + * "License") as published by the Apache Software Foundation. |
| 6 | + * |
| 7 | + * You may not use this file except in compliance with the License. You may |
| 8 | + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations |
| 14 | + * under the License. |
| 15 | + */ |
| 16 | +var __awaiter = |
| 17 | + (this && this.__awaiter) || |
| 18 | + function (thisArg, _arguments, P, generator) { |
| 19 | + function adopt(value) { |
| 20 | + return value instanceof P |
| 21 | + ? value |
| 22 | + : new P(function (resolve) { |
| 23 | + resolve(value); |
| 24 | + }); |
| 25 | + } |
| 26 | + return new (P || (P = Promise))(function (resolve, reject) { |
| 27 | + function fulfilled(value) { |
| 28 | + try { |
| 29 | + step(generator.next(value)); |
| 30 | + } catch (e) { |
| 31 | + reject(e); |
| 32 | + } |
| 33 | + } |
| 34 | + function rejected(value) { |
| 35 | + try { |
| 36 | + step(generator["throw"](value)); |
| 37 | + } catch (e) { |
| 38 | + reject(e); |
| 39 | + } |
| 40 | + } |
| 41 | + function step(result) { |
| 42 | + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); |
| 43 | + } |
| 44 | + step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 45 | + }); |
| 46 | + }; |
| 47 | +var __importDefault = |
| 48 | + (this && this.__importDefault) || |
| 49 | + function (mod) { |
| 50 | + return mod && mod.__esModule ? mod : { default: mod }; |
| 51 | + }; |
| 52 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 53 | +const utils_1 = require("../../../utils"); |
| 54 | +const error_1 = __importDefault(require("../../../error")); |
| 55 | +const querier_1 = require("../../../querier"); |
| 56 | +const normalisedURLPath_1 = __importDefault(require("../../../normalisedURLPath")); |
| 57 | +function signIn(_, options) { |
| 58 | + return __awaiter(this, void 0, void 0, function* () { |
| 59 | + const { email, password } = yield options.req.getJSONBody(); |
| 60 | + if (email === undefined) { |
| 61 | + throw new error_1.default({ |
| 62 | + message: "Missing required parameter 'email'", |
| 63 | + type: error_1.default.BAD_INPUT_ERROR, |
| 64 | + }); |
| 65 | + } |
| 66 | + if (password === undefined) { |
| 67 | + throw new error_1.default({ |
| 68 | + message: "Missing required parameter 'password'", |
| 69 | + type: error_1.default.BAD_INPUT_ERROR, |
| 70 | + }); |
| 71 | + } |
| 72 | + let querier = querier_1.Querier.getNewInstanceOrThrowError(undefined); |
| 73 | + const signInResponse = yield querier.sendPostRequest( |
| 74 | + new normalisedURLPath_1.default("/recipe/dashboard/signin"), |
| 75 | + { |
| 76 | + email, |
| 77 | + password, |
| 78 | + } |
| 79 | + ); |
| 80 | + utils_1.send200Response(options.res, signInResponse); |
| 81 | + return true; |
| 82 | + }); |
| 83 | +} |
| 84 | +exports.default = signIn; |
0 commit comments