This commit is contained in:
Jai A
2020-10-02 21:05:43 -07:00
parent d85a063db8
commit f561de200d
6 changed files with 59 additions and 8 deletions

View File

@@ -87,8 +87,8 @@
</nuxt-link> </nuxt-link>
</section> </section>
<h3>Dashboard</h3> <h3 v-if="this.$auth.loggedIn">Dashboard</h3>
<section> <section v-if="this.$auth.loggedIn">
<nuxt-link to="/dashboard/projects"> <nuxt-link to="/dashboard/projects">
<svg <svg
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -128,11 +128,20 @@
</span> </span>
</div> </div>
<section class="user-actions"> <section class="user-actions">
<div class="avatar"> <a
<img src="~/assets/images/avatar.jpg" /> v-if="!this.$auth.loggedIn"
<span> falseresync </span> :href="
'https://api.modrinth.com/api/v1/auth/init?url=http://localhost:3000' +
this.$route.path
"
class="log-in-button"
>Log In</a
>
<div v-if="this.$auth.loggedIn" class="avatar">
<img :src="this.$auth.user.avatar_url" />
<span> {{ this.$auth.user.username }} </span>
</div> </div>
<div class="notifications"> <div v-if="this.$auth.loggedIn" class="notifications">
<svg <svg
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
@@ -211,6 +220,12 @@ export default {
theme: 'light', theme: 'light',
} }
}, },
created() {
if (this.$route.query.code) {
this.$auth.setUserToken(this.$route.query.code)
console.log(this.$auth.user)
}
},
beforeMount() { beforeMount() {
const theme = localStorage.getItem('data-theme') const theme = localStorage.getItem('data-theme')
? localStorage.getItem('data-theme') ? localStorage.getItem('data-theme')
@@ -276,7 +291,7 @@ export default {
} }
.name { .name {
font-family: 'Montserrat Alternates'; font-family: 'Montserrat Alternates', serif;
margin-left: 0.4rem; margin-left: 0.4rem;
font-size: 1.3rem; font-size: 1.3rem;
} }
@@ -406,6 +421,15 @@ export default {
width: 2rem; width: 2rem;
} }
} }
.log-in-button {
text-align: center;
padding: 8px 40px;
border-radius: 5px;
color: var(--color-grey-5);
background-color: var(--color-grey-1);
margin-left: 2.5rem;
}
} }
} }

View File

@@ -45,6 +45,9 @@ export default {
}, },
], ],
}, },
router: {
middleware: ['auth'],
},
/* /*
** Global CSS ** Global CSS
*/ */
@@ -72,7 +75,22 @@ export default {
modules: [ modules: [
// Doc: https://axios.nuxtjs.org/usage // Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios', '@nuxtjs/axios',
'@nuxtjs/auth',
], ],
auth: {
strategies: {
local: {
endpoints: {
user: {
url: 'https://api.modrinth.com/api/v1/user',
method: 'get',
propertyName: false,
},
},
tokenType: false,
},
},
},
/* /*
** Axios module configuration ** Axios module configuration
** See https://axios.nuxtjs.org/options ** See https://axios.nuxtjs.org/options

View File

@@ -195,6 +195,7 @@
<script> <script>
export default { export default {
auth: false,
layout: 'none', layout: 'none',
data() { data() {
return { return {

View File

@@ -33,6 +33,12 @@
</div> </div>
</template> </template>
<script>
export default {
auth: false,
}
</script>
<style lang="scss"> <style lang="scss">
#search-pagination { #search-pagination {
align-items: center; align-items: center;

View File

@@ -68,7 +68,7 @@
:author-url="result.author_url" :author-url="result.author_url"
:page-url="result.page_url" :page-url="result.page_url"
:categories="result.categories" :categories="result.categories"
:is-ad="index % 5" :is-ad="index === -1"
/> />
</div> </div>
<section v-if="pages.length > 1" class="search-bottom"> <section v-if="pages.length > 1" class="search-bottom">
@@ -418,6 +418,7 @@ const config = {
} }
export default { export default {
auth: false,
components: { components: {
SearchResult, SearchResult,
Pagination, Pagination,

1
store/index.js Normal file
View File

@@ -0,0 +1 @@
export const state = () => ({})