var Unibase; (function (Unibase) { let Platform; (function (Platform) { let InviteUsers; (function (InviteUsers) { let Components; (function (Components) { class UserLogin extends Platform.Core.BaseComponent { cssFiles() { return []; } jsFiles() { return ["platform/inviteusers/components/userlogin.js", "platform/inviteusers/managers/inviteusermanager.js", "platform/membership/managers/accountmanager.js"]; } html(id, containerid) { let html = `
User Login
`; return html; } load(id, containerid, callback) { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var IsUser = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_loginenabled").Value; var Stagename = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_stagename").Value; if (IsUser == false) { $("#btnUserLogin").hide(); $("#userMsg").show().text("User not registered"); } else if (Stagename == "Relieved") { $("#btnUserLogin").hide(); $("#userMsg").show().text("User Relieved"); } else { var userIdentity = Unibase.Platform.Helpers.CookieHelper.Instance().getUserIdentityCookie(); if (userIdentity == "") { $("#btnUserLogin").show(); $("#userMsg").hide(); } else { $("#btnUserLogin").hide(); $("#userMsg").show().text("You are already in the child user log in.Please log out from the current user to use this option."); } } } init(containerid) { var instance = this; instance.fileCacheHelper.loadJsFiles(["platform/inviteusers/components/userlogin.js", "platform/inviteusers/managers/inviteusermanager.js"], null); instance.navigationHelper.loadSection(0, containerid, Unibase.Platform.InviteUsers.Components.UserLogin.Instance(), null, null); } userLogin() { var unibaseid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_unibaseid").Value; Unibase.Platform.Membership.Managers.AccountManager.Instance().userLogin(unibaseid).then(function (response) { if (response === undefined) { alert("Login Failed"); } else { var parentUserId = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId; var identity = response.result; identity.parentUserId = parentUserId; var cookieHelper = Unibase.Platform.Helpers.CookieHelper.Instance(); var str = JSON.stringify(Unibase.Platform.Membership.Infos.Identity.getCurrentUser()); cookieHelper.setUserIdentityCookie(str); Unibase.Platform.Membership.Infos.Identity.setCurrentUser(identity); window.location.href = '#/welcome'; window.location.reload(); MessageHelper.Instance().showSuccess(response.message, ''); } }); } static Instance() { return new UserLogin(); } } Components.UserLogin = UserLogin; })(Components = InviteUsers.Components || (InviteUsers.Components = {})); })(InviteUsers = Platform.InviteUsers || (Platform.InviteUsers = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {}));