UNPKG

cloud-ide-model-schema

Version:

Pachage for schema management of Cloud IDEsys LMS

110 lines (109 loc) 4.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MReLogin = exports.MLogin = void 0; /* INTERFACE END */ /* MODEL START */ var MLogin = /** @class */ (function () { function MLogin(init) { Object.assign(this, init); } MLogin.prototype.Validate = function () { var _a, _b; var errorLogger = {}; if (!this.user_username) { errorLogger.user_username = "Username is Required"; } /* Check mpin or password selected or not, any one from both */ if (!this.custom_login_method) { errorLogger.custom_login_method = "Login Method is Required, Mpin or Password!"; } else { if (this.custom_login_method == "pass") { /* if password is selected by user */ if (this.user_password) { /* Check wether length is in between 8 to 50 or not */ if (((_a = this.user_password) === null || _a === void 0 ? void 0 : _a.length) < 7 || ((_b = this.user_password) === null || _b === void 0 ? void 0 : _b.length) > 50) { errorLogger.user_password = "Password is Invalid!"; } } else { errorLogger.user_password = "Password is Invalid!"; } } else if (this.custom_login_method == "mpin") { /* if mpin is selected by user */ if (this.mpin_pin) { /* Check wether length is 6 or not */ if (parseInt(this.mpin_pin) < 100000 || parseInt(this.mpin_pin) > 999999) { errorLogger.mpin_pin = "MPIN is Invalid!"; } if (!(/^[0-9]+$/).test(this.mpin_pin)) { errorLogger.mpin_pin = "MPIN is Invalid!"; } } else { errorLogger.mpin_pin = "MPIN is Invalid!"; } } else { errorLogger.custom_login_method = "Login Method is Invalid, please use 'mpin' or 'pass'"; } } return errorLogger; }; return MLogin; }()); exports.MLogin = MLogin; /* INTERFACE END */ /* MODEL START */ var MReLogin = /** @class */ (function () { function MReLogin(init) { Object.assign(this, init); } MReLogin.prototype.Validate = function () { var _a, _b; var errorLogger = {}; if (!this.token) { errorLogger.token = "Token is Required"; } /* Check mpin or password selected or not, any one from both */ if (!this.custom_login_method) { errorLogger.custom_login_method = "Login Method is Required, Mpin or Password!"; } else { if (this.custom_login_method == "pass") { /* if password is selected by user */ if (this.user_password) { /* Check wether length is in between 8 to 50 or not */ if (((_a = this.user_password) === null || _a === void 0 ? void 0 : _a.length) < 7 || ((_b = this.user_password) === null || _b === void 0 ? void 0 : _b.length) > 50) { errorLogger.user_password = "Password is Invalid!"; } } else { errorLogger.user_password = "Password is Invalid!"; } } else if (this.custom_login_method == "mpin") { /* if mpin is selected by user */ if (this.mpin_pin) { /* Check wether length is 6 or not */ if (parseInt(this.mpin_pin) < 100000 || parseInt(this.mpin_pin) > 999999) { errorLogger.mpin_pin = "MPIN is Invalid!"; } if (!(/^[0-9]+$/).test(this.mpin_pin)) { errorLogger.mpin_pin = "MPIN is Invalid!"; } } else { errorLogger.mpin_pin = "MPIN is Invalid!"; } } else { errorLogger.custom_login_method = "Login Method is Invalid, please use 'mpin' or 'pass'"; } } return errorLogger; }; return MReLogin; }()); exports.MReLogin = MReLogin;