feat: redirect unauthenticated users from profile pages to home, fix auth timing on page refresh
This commit is contained in:
@@ -15,27 +15,21 @@ class PageMyListings extends HTMLElement {
|
||||
|
||||
connectedCallback() {
|
||||
this.isLoggedIn = auth.isLoggedIn()
|
||||
this.render()
|
||||
|
||||
if (this.isLoggedIn) {
|
||||
this.loadMyListings()
|
||||
} else {
|
||||
this.loading = false
|
||||
if (!this.isLoggedIn) {
|
||||
window.location.hash = '#/'
|
||||
return
|
||||
}
|
||||
|
||||
this.render()
|
||||
this.loadMyListings()
|
||||
|
||||
this.unsubscribe = i18n.subscribe(() => this.render())
|
||||
this.authUnsubscribe = auth.subscribe(() => {
|
||||
const wasLoggedIn = this.isLoggedIn
|
||||
this.isLoggedIn = auth.isLoggedIn()
|
||||
|
||||
if (!wasLoggedIn && this.isLoggedIn) {
|
||||
this.loading = true
|
||||
this.render()
|
||||
this.loadMyListings()
|
||||
} else if (wasLoggedIn && !this.isLoggedIn) {
|
||||
this.listings = []
|
||||
this.loading = false
|
||||
this.render()
|
||||
if (!this.isLoggedIn) {
|
||||
window.location.hash = '#/'
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -47,7 +41,7 @@ class PageMyListings extends HTMLElement {
|
||||
|
||||
async loadMyListings() {
|
||||
try {
|
||||
const user = auth.getUser()
|
||||
const user = await auth.getUser()
|
||||
if (!user) {
|
||||
this.loading = false
|
||||
this.updateContent()
|
||||
|
||||
Reference in New Issue
Block a user