fix(auth): cloudConfigured() reconhece login Google/email (sem token) v1.7.1
Some checks are pending
Build Android (APK + AAB) / build-android (push) Waiting to run
Some checks are pending
Build Android (APK + AAB) / build-android (push) Waiting to run
Bug crítico: após login Google ou email, o app pedia pra logar DE NOVO toda vez que abria/fechava. E sync nunca iniciava. Causa: cloudConfigured() exigia state.cloud.token, mas no login Google/email a auth fica em state.auth.accessToken (JWT), não em state.cloud.token (que é o BOAT_TOKEN avançado). Resultado: cloudConfigured() retornava false → welcome screen sempre aparecia, rtConnect() nunca rodava, sync zero. Fix: - cloudConfigured() agora retorna true se tem state.auth.accessToken OU state.cloud.token (qualquer um dos dois) - maybeShowWelcome() reescrito pra checar autenticação real - Botão "Usar sem login (modo offline)" mais visível na welcome screen pra dar saída clara Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c7994167be
commit
f8e92f3c58
5 changed files with 34 additions and 12 deletions
|
|
@ -2531,7 +2531,7 @@ Hora: {HORA}</textarea>
|
|||
<button class="welcome-btn welcome-btn-text" onclick="welcomeBack()" style="margin-top:8px">← Voltar</button>
|
||||
</div>
|
||||
|
||||
<button class="welcome-btn welcome-btn-text" onclick="welcomeSkip()" style="margin-top:14px;font-size:11px;opacity:.6">Usar offline (sem sync entre dispositivos)</button>
|
||||
<button class="welcome-btn welcome-btn-text" onclick="welcomeSkip()" style="margin-top:18px;font-size:13px;opacity:.85">⊘ Usar sem login (modo offline)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -4248,7 +4248,13 @@ function saveContactsConfig(){
|
|||
let heartbeatInterval=null;
|
||||
let cloudAutoSyncTimeout=null;
|
||||
|
||||
function cloudConfigured(){return state.cloud&&state.cloud.url&&state.cloud.token}
|
||||
function cloudConfigured(){
|
||||
if(!state.cloud||!state.cloud.url)return false;
|
||||
// Auth: tem JWT (login Google/email) OU BOAT_TOKEN (avançado/legacy)
|
||||
if(state.auth&&state.auth.accessToken)return true;
|
||||
if(state.cloud.token)return true;
|
||||
return false;
|
||||
}
|
||||
function cloudUrl(path){return state.cloud.url.replace(/\/$/,'')+path}
|
||||
|
||||
async function cloudFetch(path,opts={}){
|
||||
|
|
@ -4274,9 +4280,14 @@ const GOOGLE_CLIENT_ID_FRONTEND='989184529532-uceun7l7a12e63fdrkilnh8vml0v0lv4.a
|
|||
function maybeShowWelcome(){
|
||||
const ws=document.getElementById('welcome-screen');
|
||||
if(!ws)return;
|
||||
// Mostra se: nuvem não configurada E user não está logado E nunca dispensou
|
||||
// Mostra welcome SE: não tem auth nem token configurado E não dispensou explicitamente
|
||||
const dismissed=localStorage.getItem('shivao_welcome_dismissed')==='1';
|
||||
const needsSetup=(!cloudConfigured()||!state.auth)&&!dismissed;
|
||||
// Logado via JWT (Google/email) → não precisa welcome
|
||||
const hasJwtAuth=state.auth&&state.auth.accessToken;
|
||||
// Conectado via BOAT_TOKEN avançado → não precisa welcome
|
||||
const hasBoatToken=state.cloud&&state.cloud.token;
|
||||
const isAuthenticated=hasJwtAuth||hasBoatToken;
|
||||
const needsSetup=!isAuthenticated&&!dismissed;
|
||||
ws.style.display=needsSetup?'flex':'none';
|
||||
// Se mostrar, prepara o Google Sign-In quando carregar
|
||||
if(needsSetup&&window.google?.accounts?.id){
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ android {
|
|||
applicationId "br.com.pontualtech.shivao"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 10
|
||||
versionName "1.7.0"
|
||||
versionCode 11
|
||||
versionName "1.7.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "shivao-mobile",
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"description": "Shivao app nativo (Capacitor wrapper Android/iOS)",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -2531,7 +2531,7 @@ Hora: {HORA}</textarea>
|
|||
<button class="welcome-btn welcome-btn-text" onclick="welcomeBack()" style="margin-top:8px">← Voltar</button>
|
||||
</div>
|
||||
|
||||
<button class="welcome-btn welcome-btn-text" onclick="welcomeSkip()" style="margin-top:14px;font-size:11px;opacity:.6">Usar offline (sem sync entre dispositivos)</button>
|
||||
<button class="welcome-btn welcome-btn-text" onclick="welcomeSkip()" style="margin-top:18px;font-size:13px;opacity:.85">⊘ Usar sem login (modo offline)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -4248,7 +4248,13 @@ function saveContactsConfig(){
|
|||
let heartbeatInterval=null;
|
||||
let cloudAutoSyncTimeout=null;
|
||||
|
||||
function cloudConfigured(){return state.cloud&&state.cloud.url&&state.cloud.token}
|
||||
function cloudConfigured(){
|
||||
if(!state.cloud||!state.cloud.url)return false;
|
||||
// Auth: tem JWT (login Google/email) OU BOAT_TOKEN (avançado/legacy)
|
||||
if(state.auth&&state.auth.accessToken)return true;
|
||||
if(state.cloud.token)return true;
|
||||
return false;
|
||||
}
|
||||
function cloudUrl(path){return state.cloud.url.replace(/\/$/,'')+path}
|
||||
|
||||
async function cloudFetch(path,opts={}){
|
||||
|
|
@ -4274,9 +4280,14 @@ const GOOGLE_CLIENT_ID_FRONTEND='989184529532-uceun7l7a12e63fdrkilnh8vml0v0lv4.a
|
|||
function maybeShowWelcome(){
|
||||
const ws=document.getElementById('welcome-screen');
|
||||
if(!ws)return;
|
||||
// Mostra se: nuvem não configurada E user não está logado E nunca dispensou
|
||||
// Mostra welcome SE: não tem auth nem token configurado E não dispensou explicitamente
|
||||
const dismissed=localStorage.getItem('shivao_welcome_dismissed')==='1';
|
||||
const needsSetup=(!cloudConfigured()||!state.auth)&&!dismissed;
|
||||
// Logado via JWT (Google/email) → não precisa welcome
|
||||
const hasJwtAuth=state.auth&&state.auth.accessToken;
|
||||
// Conectado via BOAT_TOKEN avançado → não precisa welcome
|
||||
const hasBoatToken=state.cloud&&state.cloud.token;
|
||||
const isAuthenticated=hasJwtAuth||hasBoatToken;
|
||||
const needsSetup=!isAuthenticated&&!dismissed;
|
||||
ws.style.display=needsSetup?'flex':'none';
|
||||
// Se mostrar, prepara o Google Sign-In quando carregar
|
||||
if(needsSetup&&window.google?.accounts?.id){
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ app.get('/.well-known/assetlinks.json', (req, res) => {
|
|||
});
|
||||
|
||||
// Atalho: /apk redireciona pra última APK release no Forgejo
|
||||
const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.7.0/Shivao-v1.7.0.apk';
|
||||
const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.7.1/Shivao-v1.7.1.apk';
|
||||
app.get('/apk', (req, res) => res.redirect(302, LATEST_APK_URL));
|
||||
|
||||
// Página A4 imprimível com QR Code + instruções (cola no barco/marina)
|
||||
|
|
|
|||
Loading…
Reference in a new issue