2024-09-24 11:06:27 +02:00
|
|
|
window.app = Vue.createApp({
|
2020-03-04 23:11:15 +01:00
|
|
|
el: '#vue',
|
2024-09-24 11:06:27 +02:00
|
|
|
mixins: [window.windowMixin],
|
2020-03-04 23:11:15 +01:00
|
|
|
data: function () {
|
|
|
|
return {
|
2020-05-03 13:55:17 -03:00
|
|
|
disclaimerDialog: {
|
2020-04-20 15:27:02 +01:00
|
|
|
show: false,
|
2023-09-27 11:32:03 +01:00
|
|
|
data: {},
|
|
|
|
description: ''
|
2020-05-03 13:55:17 -03:00
|
|
|
},
|
2023-12-14 12:34:23 +02:00
|
|
|
isUserAuthorized: false,
|
2023-12-12 12:38:19 +02:00
|
|
|
authAction: 'login',
|
|
|
|
authMethod: 'username-password',
|
|
|
|
usr: '',
|
|
|
|
username: '',
|
|
|
|
email: '',
|
|
|
|
password: '',
|
|
|
|
passwordRepeat: '',
|
|
|
|
walletName: '',
|
|
|
|
signup: false
|
2020-05-03 13:55:17 -03:00
|
|
|
}
|
2020-03-04 23:11:15 +01:00
|
|
|
},
|
2023-09-27 11:32:03 +01:00
|
|
|
computed: {
|
|
|
|
formatDescription() {
|
|
|
|
return LNbits.utils.convertMarkdown(this.description)
|
2023-12-12 12:38:19 +02:00
|
|
|
},
|
|
|
|
isAccessTokenExpired() {
|
|
|
|
return this.$q.cookies.get('is_access_token_expired')
|
2023-09-27 11:32:03 +01:00
|
|
|
}
|
|
|
|
},
|
2020-03-04 23:11:15 +01:00
|
|
|
methods: {
|
2023-12-12 12:38:19 +02:00
|
|
|
showLogin: function (authMethod) {
|
|
|
|
this.authAction = 'login'
|
|
|
|
this.authMethod = authMethod
|
|
|
|
},
|
|
|
|
showRegister: function (authMethod) {
|
|
|
|
this.user = ''
|
|
|
|
this.username = null
|
|
|
|
this.password = null
|
|
|
|
this.passwordRepeat = null
|
|
|
|
|
|
|
|
this.authAction = 'register'
|
|
|
|
this.authMethod = authMethod
|
|
|
|
},
|
|
|
|
register: async function () {
|
|
|
|
try {
|
|
|
|
await LNbits.api.register(
|
|
|
|
this.username,
|
|
|
|
this.email,
|
|
|
|
this.password,
|
|
|
|
this.passwordRepeat
|
|
|
|
)
|
|
|
|
window.location.href = '/wallet'
|
|
|
|
} catch (e) {
|
|
|
|
LNbits.utils.notifyApiError(e)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
login: async function () {
|
|
|
|
try {
|
|
|
|
await LNbits.api.login(this.username, this.password)
|
|
|
|
window.location.href = '/wallet'
|
|
|
|
} catch (e) {
|
|
|
|
LNbits.utils.notifyApiError(e)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
loginUsr: async function () {
|
|
|
|
try {
|
|
|
|
await LNbits.api.loginUsr(this.usr)
|
|
|
|
this.usr = ''
|
|
|
|
window.location.href = '/wallet'
|
|
|
|
} catch (e) {
|
|
|
|
LNbits.utils.notifyApiError(e)
|
|
|
|
}
|
|
|
|
},
|
2020-03-04 23:11:15 +01:00
|
|
|
createWallet: function () {
|
2023-09-25 15:06:00 +02:00
|
|
|
LNbits.api.createAccount(this.walletName).then(res => {
|
|
|
|
window.location = '/wallet?usr=' + res.data.user + '&wal=' + res.data.id
|
|
|
|
})
|
2020-03-10 23:12:22 +01:00
|
|
|
},
|
|
|
|
processing: function () {
|
2024-09-24 16:18:56 +02:00
|
|
|
Quasar.Notify.create({
|
2020-03-10 23:12:22 +01:00
|
|
|
timeout: 0,
|
|
|
|
message: 'Processing...',
|
|
|
|
icon: null
|
2020-05-03 13:55:17 -03:00
|
|
|
})
|
2023-12-12 12:38:19 +02:00
|
|
|
},
|
|
|
|
validateUsername: function (val) {
|
|
|
|
const usernameRegex = new RegExp(
|
|
|
|
'^(?=[a-zA-Z0-9._]{2,20}$)(?!.*[_.]{2})[^_.].*[^_.]$'
|
|
|
|
)
|
|
|
|
return usernameRegex.test(val)
|
2020-03-04 23:11:15 +01:00
|
|
|
}
|
2023-09-27 11:32:03 +01:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.description = SITE_DESCRIPTION
|
2023-12-14 12:34:23 +02:00
|
|
|
this.isUserAuthorized = !!this.$q.cookies.get('is_lnbits_user_authorized')
|
2023-12-12 12:38:19 +02:00
|
|
|
if (this.isUserAuthorized) {
|
|
|
|
window.location.href = '/wallet'
|
|
|
|
}
|
2020-03-04 23:11:15 +01:00
|
|
|
}
|
2020-05-03 13:55:17 -03:00
|
|
|
})
|