{"title":"Login","template":"\n \u003cdiv class=\"card overflow-hidden\"\u003e\n \u003cdiv class=\"p-lg-5 p-4\"\u003e\n\n \u003cdiv\u003e\n \u003ch5 translate\u003eВойти в DamuCRM\u003c/h5\u003e\n \u003c!-- \u003cp class=\"text-muted\"\u003e\u003c/p\u003e --\u003e\n \u003c/div\u003e\n\n \u003cdiv class=\"mt-4 pt-3\"\u003e\n \u003cform [formGroup]=\"form\" (ngSubmit)=\"onSubmit()\"\u003e\n\n \u003cdiv class=\"mb-3\"\u003e\n\n \u003clabel for=\"username\" translate\u003eUsername\u003c/label\u003e\n \u003c!-- prefix=\"+7\" mask=\" (000) 000-00-00\" [showMaskTyped]=\"true\" --\u003e\n \u003cinput type=\"text\" formControlName=\"username\" class=\"form-control\" [readonly]=\"is_expired_password\"\n [ngClass]=\"{ 'is-invalid': submitted \u0026\u0026 f.username.errors }\"\n placeholder=\"{{ 'Insert Email' | translate }}\" id=\"username\" /\u003e\n \u003cdiv *ngIf=\"f.username.errors\" class=\"invalid-feedback\"\u003e\n \u003cdiv *ngIf=\"f.username.errors.required\" translate\u003eОбязательное поле\u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n\n \u003cdiv class=\"mb-3 mb-4\"\u003e\n \u003clabel translate for=\"password\"\u003ePassword\u003c/label\u003e\n \u003cinput type=\"password\" formControlName=\"password\" class=\"form-control\" [readonly]=\"is_expired_password\"\n placeholder=\"{{ 'Insert Password' | translate }}\"\n [ngClass]=\"{ 'is-invalid': service_error || (submitted \u0026\u0026 f.password.errors) }\" /\u003e\n \u003cdiv *ngIf=\"submitted \u0026\u0026 f.password.errors\" class=\"invalid-feedback\"\u003e\n \u003cdiv *ngIf=\"f.password.errors.required\" translate\u003ePassword is required\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv class=\"invalid-feedback\" *ngIf=\"service_error\" [translate]=\"service_error\"\u003e\u003c/div\u003e\n \u003c/div\u003e\n\n \u003cng-container *ngIf=\"is_expired_password\"\u003e\n\n \u003cdiv class=\"mb-3\"\u003e\n \u003clabel translate for=\"password\"\u003eNew Password\u003c/label\u003e\n \u003cinput type=\"password\" formControlName=\"new_password\" class=\"form-control\"\n minlength=\"8\" placeholder=\"{{ 'Insert Password' | translate }}\"\n [ngClass]=\"{ 'is-invalid': service_error_exp || (submitted \u0026\u0026 f.new_password.errors) }\" /\u003e\n \u003cdiv *ngIf=\"submitted \u0026\u0026 f.new_password.errors\" class=\"invalid-feedback\"\u003e\n \u003cdiv *ngIf=\"f.new_password.errors.required\" translate\u003ePassword is required\u003c/div\u003e\n \u003cdiv *ngIf=\"f.new_password.errors.pattern\" translate\u003eMust contain at least one number and one uppercase and lowercase letter\u003c/div\u003e \n \u003cdiv *ngIf=\"f.new_password.errors.minlength\" translate\u003eMust contain at least 8 or more characters\u003c/div\u003e \n \u003c/div\u003e\n \u003cdiv class=\"invalid-feedback\" [translate]=\"service_error_exp\"\u003e\u003c/div\u003e\n \u003c/div\u003e\n \n \u003cdiv class=\"mb-3 mb-4\"\u003e\n \u003clabel translate for=\"password\"\u003ePassword Confirm\u003c/label\u003e\n \u003cinput type=\"password\" formControlName=\"password_confirm\" class=\"form-control\"\n placeholder=\"{{ 'Confirm Password' | translate }}\"\n [pattern]=\"f.new_password.value\"\n [ngClass]=\"{ 'is-invalid': submitted \u0026\u0026 f.password_confirm.errors }\" /\u003e\n \u003cdiv *ngIf=\"submitted \u0026\u0026 f.password_confirm.errors\" class=\"invalid-feedback\"\u003e\n \u003cdiv *ngIf=\"f.password_confirm.errors.required\" translate\u003eConfirmed Password is required\u003c/div\u003e\n \u003cdiv *ngIf=\"f.password_confirm.errors.pattern\" translate\u003ePassword \u0026 Confirm Password does not match\u003c/div\u003e \n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/ng-container\u003e\n\n \u003cdiv class=\"row align-items-center\"\u003e\n \u003cdiv class=\"col-6\"\u003e\n \u003cbutton class=\"btn btn-primary w-md waves-effect waves-light\" type=\"submit\"\u003e{{\n (is_expired_password ? 'Change Password' : 'Login') | translate\n }}\u003c/button\u003e\n \u003c/div\u003e\n \u003cdiv class=\"col-6\"\u003e\n \u003cdiv class=\"text-end\"\u003e\n \u003cdiv class=\"form-check\"\u003e\n \u003cinput type=\"checkbox\" class=\"form-check-input font-size-16\"\n id=\"remember-check\"\u003e\n \u003clabel class=\"form-check-label\" for=\"remember-check\" translate\u003eRemember me\u003c/label\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n\n \u003cdiv class=\"mt-4\"\u003e\n \u003ca routerLink=\"/auth/forget\" class=\"text-muted\"\u003e\n \u003cspan class=\"material-icons me-1\"\u003elock\u003c/span\u003e \u003cspan translate=\"Забыли пароль?\"\u003e\u003c/span\u003e\n \u003c/a\u003e\n \u003c/div\u003e\n \u003c/form\u003e\n \u003c/div\u003e\n\n \u003c/div\u003e\n \u003c/div\u003e","json":"const vm = this;\n\nconst { FormControl, Validators } = forms;\n\nconst { first, take, distinctUntilChanged } = rxjs;\n\nconst {QueryOptions} = Models;\n\nreturn class GenClass extends vm.constructor {\n form;\n loading = false;\n submitted = false;\n is_expired_password = false;\n service_error = null;\n service_error_exp = \"\";\n\n ngOnInit() {\n \nthis.dbQueryService.restapiPost(\"c_add_ufw\",{})\n .pipe(first())\n .subscribe(items =\u003e {\n \n });\n \n this.form = this.formBuilder.group({\n username: ['', Validators.required],\n password: ['', Validators.required],\n new_password: [''],\n password_confirm: ['']\n });\n }\n\n // convenience getter for easy access to form fields\n get f() { return this.form.controls; }\n\n onSubmit() {\n this.submitted = true;\n\n // reset alerts on submit\n this.alertService.clear();\n\n // stop here if form is invalid\n if (this.form.invalid) {\n return;\n }\n\n this.loading = true;\n\n if(this.is_expired_password) {\n this.accountService.resetExpiredPassword(this.f.username.value, this.f.password.value,this.f.new_password.value)\n .subscribe((resp)=\u003e{\n this.loading = false;\n if(resp['error_code'] != 0) {\n this.service_error_exp = resp.error_text;\n this.alertService.error(this.service_error_exp);\n this.submitted = false;\n } else {\n this.login(this.f.username.value, this.f.new_password.value);\n }\n });\n } else {\n this.login(this.f.username.value, this.f.password.value);\n }\n \n }\n\n login(username,password) {\n this.accountService.login(username,password)\n .subscribe({\n next: resp =\u003e {\n this.loading = false;\n \n\n \n },\n error: (error) =\u003e {\n if (error.error){\n let resp = error.error;\n this.loading = false;\n if(resp[\"Result\"] == 'incorrect') {\n this.service_error = 'Имя пользователя или пароль неверны';\n } else if(resp[\"Result\"] == 'passwordExpired') {\n this.is_expired_password = true;\n this.service_error = 'Пароль истек';\n this.submitted = false;\n } else {\n this.service_error = 'Ошибка при проверке логина или пароля';\n }\n this.messageService.add({severity:'error', summary: 'Ошибка', detail: this.service_error});\n }else{\n this.service_error = error;\n }\n },\n complete: (resp) =\u003e {\n \n \n\n \n console.log('-=-=-=-=',resp);\n }\n });\n }\n}"}