UNPKG

cloud-ide-lms-model

Version:

Package for Model management of Cloud IDEsys LMS

108 lines (107 loc) 4.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MReLogin = exports.MLogin = void 0; /* INTERFACE END */ /* MODEL START */ class MLogin { constructor(init) { Object.assign(this, init); } Validate() { var _a, _b; let 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; } } exports.MLogin = MLogin; /* INTERFACE END */ /* MODEL START */ class MReLogin { constructor(init) { Object.assign(this, init); } Validate() { var _a, _b; let 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; } } exports.MReLogin = MReLogin;