Flusso FE ottimizzato

API QN* → /?action=... · Mockup: /mockupfe

Obiettivo

Il flusso classico (flusso.html + /mockup) resta invariato. Il FE ottimizzato usa azioni dedicate: QNLogin, QNLoginSocial, QNVerifyOtp, QNRegister, QNUpdateProfile, QNAddPhone. Rispondono con next_step (stessi numeri del flusso classico) oppure access_token.

Diagramma flusso login mockupfe

Pagine /mockupfe · API QN* · numeri = next_step

flowchart TD Start(["index.html
email / telefono / social"]) --> QNL["QNLogin"] Start --> SOC["QNLoginSocial
phase=start"] QNL -->|next_step 14
flow phone| OTP["otp.html
OTP SMS #14"] QNL -->|next_step 33
flow email_verify| OTPE["otp-email.html
OTP email #33"] SOC --> REDIR["Redirect Google/FB"] REDIR --> CB["social-callback.html
phase=code"] CB -->|OK → #50| S50{"ha otp_phone?"} CB -->|ADDITIONAL_INPUT| CONS["social-consents.html
phase=additional"] CB -->|CONFIRM| CONF["social-confirm.html
passwordless Piano + phase=confirm"] CONS --> S50 CONF --> S50 S50 -->|sì → #65/#90| OK(["success / newsletters
token + __utp"]) S50 -->|no → #61| PH2["phone.html
QNAddPhone #61"] OTP --> QNV1["QNVerifyOtp"] QNV1 -->|next_step 90| OK QNV1 -->|next_step 20
nuovo utente + phone_proof| REG["register.html
QNRegister phase=email_otp #22"] REG --> OTPE2["otp-email.html
OTP email #23"] OTPE2 --> QNV2["QNVerifyOtp #24
+ register_proof #24b"] QNV2 -->|next_step 25| PROF["profile.html #25
anagrafica + consensi"] PROF -->|register_proof| REG2["QNRegister #21
consensi+register+token"] REG2 -->|next_step 90| OK OTPE --> QNV3["QNVerifyOtp #34"] QNV3 -->|OTP ko| OTPE QNV3 -->|OTP ok → #30/#31/#50| QNV3b{"branch"} QNV3b -->|#50 sì → #65| OK QNV3b -->|next_step 37 + email_proof| PH["phone.html
QNAddPhone #37"] QNV3b -->|next_step 61 + uid| PH2 PH -->|phone_taken| ERR(["Errore
telefono già usato"]) PH -->|next_step 62| OTPP["otp-phone.html
OTP SMS #39"] OTPP --> QNV4["QNVerifyOtp"] QNV4 -->|next_step 41 + register_proof| PROF2["profile.html #41
consensi + anagrafica"] PROF2 -->|QNRegister #35| OK PH2 -->|next_step 62| OTPP2["otp-phone.html #62"] OTPP2 --> QNV5["QNVerifyOtp"] QNV5 -->|next_step 63| PROF3["profile.html #63 = #25
prefill anagrafica → QNUpdateProfile"] PROF3 --> OK classDef page fill:#e0f2f1,stroke:#00695c,color:#004d40; classDef api fill:#fff3e0,stroke:#e65100,color:#bf360c; classDef ok fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20; classDef err fill:#ffcdd2,stroke:#c62828,color:#b71c1c; class Start,OTP,OTPE,REG,OTPE2,PH,PH2,OTPP,OTPP2,PROF,PROF2,PROF3,CB,CONS,CONF,REDIR page; class QNL,QNV1,QNV2,QNV3,QNV3b,QNV4,QNV5,REG2,SOC,S50 api; class OK ok; class ERR err;

Overview chiamate FE (sintesi)

flowchart LR subgraph FE["/mockupfe"] F1[Login] --> F2["QNLogin"] F1 --> FS["QNLoginSocial start"] FS --> FSc[Callback code] FSc -->|CONFIRM| FSo["confirm_send mail Piano"] FSo --> FSc2["phase=confirm passwordless_token"] FSc -->|OK| F50["#50 telefono?"] FSc2 --> F50 F50 -->|#65/#90| FOK[OK + token] F50 -->|#61| F61["QNAddPhone #61"] F2 -->|#14| F3[OTP SMS] F2 -->|#33| F3e[OTP email] F3 --> F4["QNVerifyOtp phone"] F4 -->|#90| FOK F4 -->|#20| F5["QNRegister phase=email_otp #22"] F5 --> F6[OTP email #23] F6 --> F4b["QNVerifyOtp #24"] F4b -->|#25| F7[Profilo] F7 -->|#21| F5b["QNRegister → #90"] F5b --> FOK F3e --> F4e["QNVerifyOtp #34 + #30/#31/#50"] F4e -->|#65/#90| FOK F4e -->|#37| FPH[Telefono register] F4e -->|#61| F61 F61 --> F62["QNVerifyOtp #62"] F62 --> F7b["QNUpdateProfile → #90"] F7b --> FOK end

1) QNLogin

POST ?action=QNLogin · { "identifier": "email|telefono" }

Orchestra fino a 14 (telefono, OTP SMS #13) o 33 (email, OTP #32).

next_stepflowSchermata
14phoneotp.html
33email_verifyotp-email.html

2) QNVerifyOtp

POST ?action=QNVerifyOtp

Se OTP ok e non serve registrazione → search + token → next_step: 90 + access_token. Lato server, dopo il token viene eseguito User Collector ingest (non è una chiamata FE).

{
  "otp_code": "1234",
  "flow": "phone",
  "phone": "3331234567",
  "email": "user@mail.it",
  "uid": "",
  "stay_logged_in": true
}
flowEsito
phone#90 token oppure #20 register
email_with_phone#90 token
email_verify#34: OTP ko → #33; OTP ok → #30/#31/#50 → #37 / #61 / #65; account di un'altra app del gruppo → #60 password
phone_register#25 profilo (+ register_proof) → poi #21; email già di un account: di un'altra app del gruppo → #60 password; con telefono → token (done); senza telefono → #63 profilo, che salva il telefono con l'anagrafica
email_register_phone#41 profilo (+ register_proof) → poi #35
email_add_phone#63 profilo → QNUpdateProfile

3) QNRegister

POST ?action=QNRegister — fasi con proof firmati (no sessione).

Phone: #22→#25→#21 → #90. Email: #34→#37–39→#41→#35 (stessa chiamata: register con is_confirmed_email + consensi custom + update #40+#42) → #90.

{
  "phase": "email_otp",
  "email": "new@mail.it",
  "phone": "3331234567",
  "phone_proof": "...",
  "flow": "phone_register"
}
{
  "phase": "register",
  "email": "new@mail.it",
  "phone": "3331234567",
  "register_proof": "...",
  "consents": {
    "terms_conditions": true,
    "profiling_consent": false,
    "marketing_consent": true
  },
  "first_name": "Luca",
  "last_name": "Rossi",
  "birth_date": "1990-01-15",
  "city": "Milano",
  "flow": "phone_register"
}

4) QNUpdateProfile

POST ?action=QNUpdateProfile — unisce update_profile + access_token.

{
  "uid": "PNI...",
  "first_name": "Luca",
  "last_name": "Rossi",
  "birth_date": "1990-01-15",
  "city": "Milano",
  "otp_phone": "3331234567",
  "email": "user@mail.it",
  "stay_logged_in": true
}
{
  "success": true,
  "data": {
    "next_step": 90,
    "done": true,
    "uid": "PNI...",
    "access_token": "...",
    "screen": "success"
  }
}

5) QNAddPhone

POST ?action=QNAddPhone — step 61–62 (dopo login password o registrazione email).

Prima di inviare l’OTP verifica che otp_phone non sia già usato. Se esiste → errore phone_taken.

{
  "phone": "3331234567",
  "uid": "PNI...",
  "email": "user@mail.it",
  "flow": "email_add_phone"
}

6) QNLoginPassword

POST ?action=QNLoginPassword — step 60, per un account di un'altra app Piano del gruppo (Carlino, Nazione, Giorno) che entra per la prima volta in questa.

In Global Mode l'email trova l'account in tutte le app, ma Piano tiene un profilo per app e lo crea solo quando l'utente accede a quell'app. Senza profilo Piano non salva telefono e anagrafica (Invalid uid). Dopo il codice email QNVerifyOtp risponde next_step: 60, screen: password, password_proof e account_app (testata dell'account, o null); con la password dell'account Piano crea il profilo qui. Una volta sola: dalla volta dopo l'account è come gli altri.

{
  "password_proof": "...",
  "password": "..."
}

Unicità telefono

Mappa mockupfe

PaginaAPINote
index.htmlQNLogin / QNLoginSocial#14 / #33 · social → redirect
social-callback.htmlQNLoginSocial phase=codeOK / CONFIRM / ADDITIONAL_INPUT
social-confirm.htmlQNLoginSocial confirm_send + confirmmail passwordless Piano → #50
social-consents.htmlQNLoginSocial phase=additionalconsensi → #50
otp.htmlQNVerifyOtp#90 o #20
otp-email.htmlQNVerifyOtp#24 → #25 profilo · oppure #34 → #37 telefono · account di un'altra app → #60 password
register.htmlQNRegister phase=email_otp#22 OTP email (serve phone_proof)
register-email.html—redirect a phone (consensi in #35)
password.htmllogin#60 → phone (legacy)
phone.htmlQNAddPhone#37/#61 + pending_proof se email_register
otp-phone.htmlQNVerifyOtp#39 → #41 · oppure #62 → #63
profile.htmlQNRegister o QNUpdateProfilecon register_proof → #21/#35; altrimenti update
newsletters.htmlnewsletter_*dopo auth
success.htmlQNUserAccessListvalida __utp poi Piano publisher/user/access/list (uid)
recommendations.htmlrecommendationscontenuti suggeriti Cxense (url + toptrend opz.)