import XNode from "@web-atoms/core/dist/core/XNode"; import { ContentPage } from "@web-atoms/web-controls/dist/mobile-app/MobileApp"; import Form from "@web-atoms/web-controls/dist/basic/Form"; import FormField from "@web-atoms/web-controls/dist/basic/FormField"; import { ILoginSession, LoginSession } from "../../../../model/model"; import Bind from "@web-atoms/core/dist/core/Bind"; import PasswordBox from "@web-atoms/web-controls/dist/basic/PasswordBox"; import Action from "@web-atoms/core/dist/view-model/Action"; import InjectProperty from "@web-atoms/core/dist/core/InjectProperty"; import LoginService from "../../../../services/LoginService"; import ToggleButtonBar from "@web-atoms/web-controls/dist/basic/ToggleButtonBar"; import { SaveIconTextButton } from "../../../../controls/buttons/IconButton"; import PasswordStrength from "../../../../controls/password/PasswordStrength"; import { Validators } from "../../../../controls/validators/Validators"; const authTypes = [{ label: "Authenticator (TOTP)", value: "totp" }, { label: "One Time Password", value: "one-time" } ]; export default class LoginPage extends ContentPage { @InjectProperty private userService: LoginService; private model: ILoginSession; private password?: string = ""; private authType = "totp"; async init() { this.model = LoginSession.create({}); this.model.userName = ""; this.model.checkPassword = ""; this.model.timeToken = ""; this.model.oneTimePassword = ""; this.render(
this.model.userName)}/> this.model.checkPassword)} />
); } @Action({ onEvent: "login" }) async login() { const status = await this.userService.login(this.model); if (!status) { return; } if (status === "change-password") { await this.showChangePassword(); return; } this.renderer =
this.authType)}/> this.authType === "totp")}> this.model.timeToken)}/> this.authType !== "totp")}> this.model.oneTimePassword)}/>
this.login()} text="Go" />
; } async showChangePassword() { this.model.newPassword = ""; this.renderer =
Update your password, your one time password is expired.
Validators.isValidPassword(this.password) ? "" : "Password must contain one symbol, one number and should be minimum 7 characters" )}> this.password)} /> this.password)} /> this.model.newPassword !== this.password ? "Passwords do not match" : "")}> this.model.newPassword)} />
; } }