More secure custom authentication solution (#126)

* Remove Nuxt Auth from the project, and switch to a custom solution

* Replace old testing code

* Remove warnings

* Add comments to hard to understand function calls in middleware

* Use arrow functions
This commit is contained in:
Geometrically
2021-03-29 09:43:00 -07:00
committed by GitHub
parent 8911bdf966
commit 24c8e29691
23 changed files with 271 additions and 614 deletions

View File

@@ -19,7 +19,7 @@
<p v-if="user.bio" class="bio">{{ user.bio }}</p>
<div class="buttons">
<nuxt-link
v-if="this.$auth.loggedIn"
v-if="this.$auth.user"
:to="`/report/create?id=${user.id}&t=user`"
class="iconified-button"
>
@@ -102,32 +102,19 @@ export default {
ReportIcon,
},
async asyncData(data) {
const config = {
headers: {
Authorization: data.$auth.getToken('local')
? data.$auth.getToken('local')
: '',
},
}
try {
let res = await axios.get(
`https://api.modrinth.com/api/v1/user/${data.params.id}`,
config
`https://api.modrinth.com/api/v1/user/${data.params.id}`
)
const user = res.data
let mods = []
res = await axios.get(
`https://api.modrinth.com/api/v1/user/${user.id}/mods`,
config
`https://api.modrinth.com/api/v1/user/${user.id}/mods`
)
if (res.data) {
res = await axios.get(
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(
res.data
)}`,
config
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`
)
mods = res.data
}
@@ -250,7 +237,4 @@ export default {
}
}
}
.mods {
}
</style>