Drop visible +994 label, simpler cert confirm, re-auth on company rollback
- Remove the +994 badge from the phone input; it's applied silently on submit. Placeholder simplified to "Enter number". Prefix select gets an explicit border + white background so it stays visible under custom themes. - Cert-pick confirm dialog shrinks to a single-line "Confirm selection: X?". - "Wrong company? Change" now does a proper restart: the backend reset also wipes bearer_token / certificates_json / verification_code and flips auth_status back to "Not Authenticated", because e-taxes' bearer_token is single-use per chooseTaxpayer. The JS immediately calls handle_authentication to pull a fresh token — another SMS + phone tap produces a new certs list without the 401 "Authentication required" that was surfacing when re-using the consumed bearer_token.
This commit is contained in:
parent
6422129c53
commit
cab4131803
|
|
@ -1 +1 @@
|
|||
__version__ = "0.0.9"
|
||||
__version__ = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -63,19 +63,24 @@ def get_company_from_cert(asan_login_name):
|
|||
|
||||
@frappe.whitelist()
|
||||
def reset_company_selection(asan_login_name):
|
||||
"""Roll back after a wrong certificate pick: wipe main_token / selected cert on
|
||||
Asan Login and clear the wizard cache (both e-taxes and AMAS) so the user can
|
||||
pick a different taxpayer and re-fetch from scratch. Certificates list itself
|
||||
is not touched — it's still valid for the same Asan ID.
|
||||
"""Roll back after a wrong certificate pick. The e-taxes bearer_token is
|
||||
single-use per chooseTaxpayer call, so we wipe the full auth state — the
|
||||
caller is expected to immediately re-run handle_authentication to obtain a
|
||||
fresh bearer_token via another phone tap. Also clears the wizard cache
|
||||
(both e-taxes and AMAS) so the next pick starts from a clean slate.
|
||||
"""
|
||||
_only_admin()
|
||||
|
||||
doc = frappe.get_doc("Asan Login", asan_login_name)
|
||||
doc.bearer_token = ""
|
||||
doc.main_token = ""
|
||||
doc.certificates_json = ""
|
||||
doc.selected_certificate = ""
|
||||
doc.selected_certificate_index = ""
|
||||
doc.selected_certificate_json = ""
|
||||
doc.choose_taxpayer_response = ""
|
||||
doc.verification_code = ""
|
||||
doc.auth_status = "Not Authenticated"
|
||||
doc.flags.ignore_permissions = True
|
||||
doc.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ frappe.provide("jey_wizard");
|
|||
// Bump this string in every commit that changes wizard code. Displayed in the badge so
|
||||
// we can tell at a glance which version is actually running on a given machine. Kept in
|
||||
// sync with __version__ in jey_wizard/__init__.py.
|
||||
const JEY_WIZARD_VERSION = "0.0.9";
|
||||
const JEY_WIZARD_VERSION = "0.1.0";
|
||||
|
||||
// Wipe Frappe + ERPNext default slides so their `before_load`/`after_load` listeners
|
||||
// don't try to mutate a wizard that isn't slide-based anymore.
|
||||
|
|
@ -145,8 +145,10 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
|
||||
render_asan($body) {
|
||||
if (this.asan_state === "input") {
|
||||
// +994 is hardcoded (every Azerbaijani mobile uses it); the visible
|
||||
// parts are the carrier prefix (dropdown) and the 7-digit local number.
|
||||
// +994 is prefixed silently on submit — we don't render it in the UI
|
||||
// because it's the only possibility for Azerbaijani mobile numbers and
|
||||
// a static label clutters the form. The visible parts are the carrier
|
||||
// prefix (dropdown) and the 7-digit local number.
|
||||
const prefixOptions = ["50", "51", "10", "55", "60", "70", "77", "99"]
|
||||
.map((p) => `<option value="${p}">0${p}</option>`)
|
||||
.join("");
|
||||
|
|
@ -154,13 +156,12 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
<h3 style="margin-bottom:16px">${__("Asan Imza authentication")}</h3>
|
||||
<div style="margin-bottom:12px">
|
||||
<label style="display:block;margin-bottom:4px">${__("Phone number")}</label>
|
||||
<div style="display:flex;align-items:center;gap:6px;max-width:320px">
|
||||
<span style="padding:6px 10px;background:#f0f0f0;border:1px solid #d1d1d1;border-radius:4px;color:#555">+994</span>
|
||||
<select class="jey-asan-prefix form-control" style="width:80px">
|
||||
<div style="display:flex;align-items:center;gap:8px;max-width:320px">
|
||||
<select class="jey-asan-prefix form-control" style="width:90px;border:1px solid #bcc2ca;border-radius:4px;padding:6px 8px;background:#fff">
|
||||
<option value="">${__("Prefix")}</option>
|
||||
${prefixOptions}
|
||||
</select>
|
||||
<input type="text" inputmode="numeric" maxlength="7" class="jey-asan-phone form-control" style="flex:1" placeholder="${__("7 digits")}" />
|
||||
<input type="text" inputmode="numeric" maxlength="7" class="jey-asan-phone form-control" style="flex:1" placeholder="${__("Enter number")}" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-bottom:12px">
|
||||
|
|
@ -708,11 +709,8 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
if (!cert) return;
|
||||
const legal = cert.legalInfo || {};
|
||||
const certName = `${legal.name || ""} (${legal.voen || legal.tin || ""})`;
|
||||
// Cert selection triggers a cascade (select_taxpayer → fetch_etaxes_data) that
|
||||
// writes a lot of cached data. Picking the wrong cert is reversible but costs
|
||||
// another phone tap, so confirm explicitly first.
|
||||
frappe.confirm(
|
||||
__("You selected {0}. Is this the right company? Switching later will require clearing loaded data and re-authenticating.", [frappe.utils.escape_html(certName)]),
|
||||
__("Confirm selection: {0}?", [frappe.utils.escape_html(certName)]),
|
||||
() => this.pick_certificate(idx),
|
||||
() => {}
|
||||
);
|
||||
|
|
@ -778,11 +776,12 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
|
||||
reset_company_selection() {
|
||||
// Reached from asan/done when the user realizes they picked the wrong cert.
|
||||
// Warn explicitly — we wipe both the e-taxes cache and the AMAS selection,
|
||||
// and clear the certificate/main_token on Asan Login. Cert list stays in
|
||||
// this.asan_certificates so the user can pick again without re-polling.
|
||||
// The e-taxes bearer_token is single-use per chooseTaxpayer call, so after
|
||||
// the first select_taxpayer it can't be reused — the server returns 401.
|
||||
// The only way to pick a different cert is to run a fresh auth round
|
||||
// (another SMS + phone tap). We warn about that explicitly.
|
||||
frappe.confirm(
|
||||
__("This will delete all loaded tax portal data and any ƏMAS employee selection. You will need to pick a certificate again. Continue?"),
|
||||
__("This will clear loaded data and ƏMAS selection, and send a new confirmation request to your phone. Continue?"),
|
||||
() => {
|
||||
frappe.call({
|
||||
method: "jey_wizard.api.reset_company_selection",
|
||||
|
|
@ -805,8 +804,13 @@ frappe.setup.SetupWizard = class JeySetupWizard {
|
|||
this.amas_state = "intro";
|
||||
this.asan_fetch_summary = {};
|
||||
this.asan_fetch_errors = {};
|
||||
this.asan_state = "certs";
|
||||
this.show_current_step();
|
||||
this.asan_certificates = [];
|
||||
this.asan_bearer_token = "";
|
||||
this.asan_verification_code = "";
|
||||
// Kick off a fresh auth round. Phone and user_id are still on
|
||||
// the Asan Login record, so handle_authentication works without
|
||||
// re-prompting the user.
|
||||
this.trigger_asan_authentication();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ Phone number,Telefon nömrəsi
|
|||
e.g. 0501234567,məsələn 0501234567
|
||||
Prefix,Prefiks
|
||||
7 digits,7 rəqəm
|
||||
Enter number,Nömrəni daxil edin
|
||||
Select a phone prefix,Telefon prefiksini seçin
|
||||
Phone number must be 7 digits,Telefon nömrəsi 7 rəqəmdən ibarət olmalıdır
|
||||
User ID is required,User ID tələb olunur
|
||||
"You selected {0}. Is this the right company? Switching later will require clearing loaded data and re-authenticating.","Siz {0} seçdiniz. Bu, düzgün şirkətdir? Sonradan dəyişmək üçün yüklənmiş məlumatları silmək və yenidən giriş etmək lazım olacaq."
|
||||
"This will delete all loaded tax portal data and any ƏMAS employee selection. You will need to pick a certificate again. Continue?","Vergi portalından yüklənmiş bütün məlumatlar və seçilmiş ƏMAS işçiləri silinəcək. Sertifikatı yenidən seçmək lazım gələcək. Davam edilsin?"
|
||||
"Confirm selection: {0}?","Seçimi təsdiq edin: {0}?"
|
||||
"This will clear loaded data and ƏMAS selection, and send a new confirmation request to your phone. Continue?","Yüklənmiş məlumatlar və ƏMAS seçimi silinəcək, telefonunuza yeni təsdiq sorğusu göndəriləcək. Davam edilsin?"
|
||||
Clearing...,Silinir...
|
||||
Failed to clear data.,Məlumatı silmək alınmadı.
|
||||
Wrong company? Change,Yanlış şirkət? Dəyiş
|
||||
|
|
|
|||
|
|
|
@ -6,11 +6,12 @@ Phone number,Номер телефона
|
|||
e.g. 0501234567,например 0501234567
|
||||
Prefix,Префикс
|
||||
7 digits,7 цифр
|
||||
Enter number,Введите номер
|
||||
Select a phone prefix,Выберите префикс номера
|
||||
Phone number must be 7 digits,Номер телефона должен содержать 7 цифр
|
||||
User ID is required,User ID обязателен
|
||||
"You selected {0}. Is this the right company? Switching later will require clearing loaded data and re-authenticating.","Вы выбрали {0}. Это нужная компания? Смена выбора позже потребует удаления загруженных данных и повторной авторизации."
|
||||
"This will delete all loaded tax portal data and any ƏMAS employee selection. You will need to pick a certificate again. Continue?","Будут удалены все загруженные данные с налогового портала и выбранные сотрудники ƏMAS. Вам потребуется выбрать сертификат заново. Продолжить?"
|
||||
"Confirm selection: {0}?","Подтвердите выбор: {0}?"
|
||||
"This will clear loaded data and ƏMAS selection, and send a new confirmation request to your phone. Continue?","Будут очищены загруженные данные и выбор ƏMAS, и на ваш телефон придёт новый запрос подтверждения. Продолжить?"
|
||||
Clearing...,Очистка...
|
||||
Failed to clear data.,Не удалось очистить данные.
|
||||
Wrong company? Change,Не та компания? Сменить
|
||||
|
|
|
|||
|
Loading…
Reference in New Issue