Fix login with oauth (#2935)

This commit is contained in:
Tiago Vasconcelos 2025-02-07 14:48:22 +00:00 committed by GitHub
parent a8809ed5a4
commit 503a599341
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 209 additions and 197 deletions

View file

@ -98,26 +98,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if lnurl and LNBITS_NEW_ACCOUNTS_ALLOWED and ("user-id-only" in
LNBITS_AUTH_METHODS)%}
<div class="row">
<div class="full-width q-mb-md">
<q-card>
<q-card-section>
<q-btn
unelevated
color="primary"
@click="processing"
type="a"
href="/lnurlwallet?lightning={{ lnurl }}"
v-text="$t('press_to_claim')"
class="full-width"
></q-btn>
</q-card-section>
</q-card>
</div>
</div>
{%else%} {% endif %}
<div class="row"> <div class="row">
<q-badge <q-badge
v-if="isAccessTokenExpired" v-if="isAccessTokenExpired"
@ -129,13 +110,33 @@
<span v-text="$t('session_has_expired')"></span> <span v-text="$t('session_has_expired')"></span>
</div> </div>
</q-badge> </q-badge>
<q-card bordered class="full-width q-pt-md"> <q-card bordered class="full-width q-py-md">
<div class="row"> <div class="row">
<div <div
class="col-12" class="col-12"
:class="{'col-sm-7' : '{{ LNBITS_CUSTOM_IMAGE }}', 'col-lg-6' : '{{ LNBITS_CUSTOM_IMAGE }}'}" :class="{'col-sm-7' : '{{ LNBITS_CUSTOM_IMAGE }}', 'col-lg-6' : '{{ LNBITS_CUSTOM_IMAGE }}'}"
> >
{% if "username-password" in LNBITS_AUTH_METHODS %} {% if lnurl and LNBITS_NEW_ACCOUNTS_ALLOWED and ("user-id-only"
in LNBITS_AUTH_METHODS)%}
<div class="full-height content-center">
<q-card-section>
<div class="text-body1">
<span v-text="$t('claim_desc')"></span>
</div>
</q-card-section>
<q-card-section>
<q-btn
unelevated
color="primary"
@click="processing"
type="a"
href="/lnurlwallet?lightning={{ lnurl }}"
v-text="$t('press_to_claim')"
class="full-width"
></q-btn>
</q-card-section>
</div>
{%else%}
<username-password <username-password
v-if="authMethod != 'user-id-only'" v-if="authMethod != 'user-id-only'"
:allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}" :allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}"
@ -171,7 +172,7 @@
</p> </p>
</div> </div>
</username-password> </username-password>
{%endif%} {% if "user-id-only" in LNBITS_AUTH_METHODS %} {% if "user-id-only" in LNBITS_AUTH_METHODS %}
<user-id-only <user-id-only
:allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}" :allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}"
v-model:usr="usr" v-model:usr="usr"
@ -184,7 +185,7 @@
@create-wallet="createWallet" @create-wallet="createWallet"
> >
</user-id-only> </user-id-only>
{%endif%} {%endif%} {% endif %}
</div> </div>
<div <div
class="col-sm-5 col-lg-6 gt-xs" class="col-sm-5 col-lg-6 gt-xs"
@ -202,7 +203,7 @@
</q-card> </q-card>
</div> </div>
</div> </div>
<div class="full-width q-mb-xl q-mt-sm"> <div class="full-width q-mb-lg q-mt-sm">
<div class="flex flex-center q-gutter-md q-py-md"> <div class="flex flex-center q-gutter-md q-py-md">
<q-btn <q-btn
outline outline
@ -226,6 +227,35 @@
></q-btn> ></q-btn>
</div> </div>
</div> </div>
{% if AD_SPACE %}
<div class="row justify-center q-mb-xl">
<div class="full-width text-center">
<span class="text-uppercase text-grey">{{ AD_SPACE_TITLE }}</span>
</div>
<div class="flex flex-center columm">
{% for ADS in AD_SPACE %} {% set AD = ADS.split(';') %}
<div class="flex flex-center column">
<a href="{{ AD[0] }}">
<img
v-if="($q.dark.isActive)"
src="{{ AD[1] }}"
style="max-width: 420px"
class="full-width"
/>
<img
v-else
src="{{ AD[2] }}"
style="max-width: 420px"
class="full-width"
/>
</a>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class="full-width"> <div class="full-width">
<div class="wrapper"> <div class="wrapper">
<div class="marquee"> <div class="marquee">
@ -623,35 +653,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if AD_SPACE %} {% endblock %}
<div class="row justify-center q-mt-xl">
<div class="full-width q-mb-md text-center">
<span class="text-uppercase text-grey">{{ AD_SPACE_TITLE }}</span>
</div>
<div class="flex flex-center columm">
{% for ADS in AD_SPACE %} {% set AD = ADS.split(';') %}
<div class="flex flex-center column">
<a href="{{ AD[0] }}">
<img
v-if="($q.dark.isActive)"
src="{{ AD[1] }}"
style="max-width: 420px"
class="full-width"
/>
<img
v-else
src="{{ AD[2] }}"
style="max-width: 420px"
class="full-width"
/>
</a>
</div>
{% endfor %}
</div>
</div>
{% endif %} {% endblock %}
</q-page> </q-page>
</q-page-container> </q-page-container>
{% endblock %} {% endblock %}

View file

@ -471,7 +471,7 @@ async def lnurlwallet(request: Request, lightning: str = ""):
res2.raise_for_status() res2.raise_for_status()
return RedirectResponse( return RedirectResponse(
f"/wallet?wal={wallet.id}", f"/wallet?usr={account.id}&wal={wallet.id}",
) )

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -58,6 +58,8 @@ window.localisation.en = {
currency: 'Currency', currency: 'Currency',
update_currency: 'Update currency', update_currency: 'Update currency',
press_to_claim: 'Press to claim bitcoin', press_to_claim: 'Press to claim bitcoin',
claim_desc:
'It seems you have a claimable amount of bitcoin but you dont have a wallet yet. Press the button below to claim it. This will create a new wallet for you.',
donate: 'Donate', donate: 'Donate',
view_github: 'View on GitHub', view_github: 'View on GitHub',
voidwallet_active: 'VoidWallet is active! Payments disabled', voidwallet_active: 'VoidWallet is active! Payments disabled',
@ -270,7 +272,8 @@ window.localisation.en = {
login_to_account: 'Login to your account', login_to_account: 'Login to your account',
create_account: 'Create account', create_account: 'Create account',
account_settings: 'Account Settings', account_settings: 'Account Settings',
signin_with_oauth: 'or Login with', signin_with_oauth: 'Login with',
signin_with_oauth_or: 'or Login with',
signin_with_nostr: 'Continue with Nostr', signin_with_nostr: 'Continue with Nostr',
signin_with_google: 'Sign in with Google', signin_with_google: 'Sign in with Google',
signin_with_github: 'Sign in with GitHub', signin_with_github: 'Sign in with GitHub',

View file

@ -523,7 +523,7 @@ window.app.component('user-id-only', {
this.$emit('show-register', method) this.$emit('show-register', method)
}, },
loginUsr() { loginUsr() {
this.$emit('update:user', this.user) this.$emit('update:usr', this.user)
this.$emit('login-usr') this.$emit('login-usr')
}, },
createWallet() { createWallet() {
@ -599,9 +599,7 @@ window.app.component('username-password', {
return this.oauth.some(m => this.authMethods.includes(m)) return this.oauth.some(m => this.authMethods.includes(m))
} }
}, },
created() { created() {}
console.log('username-password created', this.passwordRepeat)
}
}) })
window.app.component('separator-text', { window.app.component('separator-text', {

View file

@ -20,9 +20,7 @@ window.app = Vue.createApp({
password: '', password: '',
passwordRepeat: '', passwordRepeat: '',
walletName: '', walletName: '',
signup: false, signup: false
slide: 1,
autoplay: true
} }
}, },
computed: { computed: {
@ -177,7 +175,6 @@ window.app = Vue.createApp({
} }
}, },
created() { created() {
console.log(Quasar.LocalStorage.getItem('lnbits.disclaimerShown'))
this.description = SITE_DESCRIPTION this.description = SITE_DESCRIPTION
this.isUserAuthorized = !!this.$q.cookies.get('is_lnbits_user_authorized') this.isUserAuthorized = !!this.$q.cookies.get('is_lnbits_user_authorized')
if (this.isUserAuthorized) { if (this.isUserAuthorized) {

View file

@ -1157,6 +1157,7 @@
</template> </template>
<template id="username-password"> <template id="username-password">
<div v-if="authMethods.includes('username-password')">
<q-card-section class="q-pb-none"> <q-card-section class="q-pb-none">
<div class="text-center text-h6 q-mb-sm q-mt-none q-pt-none"> <div class="text-center text-h6 q-mb-sm q-mt-none q-pt-none">
<span <span
@ -1167,7 +1168,10 @@
v-if="authAction === 'register'" v-if="authAction === 'register'"
v-text="$t('create_account')" v-text="$t('create_account')"
></span> ></span>
<span v-if="authAction === 'reset'" v-text="$t('reset_password')"></span> <span
v-if="authAction === 'reset'"
v-text="$t('reset_password')"
></span>
</div> </div>
</q-card-section> </q-card-section>
<!-- LOGIN --> <!-- LOGIN -->
@ -1288,9 +1292,17 @@
</div> </div>
</q-form> </q-form>
</q-card-section> </q-card-section>
</div>
<!-- OAUTH --> <!-- OAUTH -->
<q-card-section v-if="showOauth"> <q-card-section v-if="showOauth">
<separator-text :text="$t('signin_with_oauth')"></separator-text> <div v-if="authMethods.includes('username-password')">
<separator-text :text="$t('signin_with_oauth_or')"></separator-text>
</div>
<q-card-section v-else class="q-pb-none">
<div class="text-center text-h6">
<span v-text="$t('signin_with_oauth')"></span>
</div>
</q-card-section>
<div class="flex justify-center q-mt-md" style="gap: 1rem"> <div class="flex justify-center q-mt-md" style="gap: 1rem">
<q-btn <q-btn
v-if="authMethods.includes('nostr-auth-nip98')" v-if="authMethods.includes('nostr-auth-nip98')"