Skip to content

Commit

Permalink
account activation
Browse files Browse the repository at this point in the history
  • Loading branch information
aiomayo committed Jun 22, 2024
1 parent 23c47fc commit 23bf785
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Pfps from '../views/PfpsView.vue';
import Wallpapers from '../views/WallpapersView.vue';
import Settings from '../views/SettingsView.vue';
import MyScape from '../views/MyScape.vue';

import ActivateAccount from '../views/ActivateAccountView.vue';
const routes = [
{ path: '/', component: Home },
{ path: '/pfps', component: Pfps },
Expand All @@ -15,6 +15,7 @@ const routes = [
{ path: '/login', component: Login },
{ path: '/settings', component: Settings },
{ path: '/myscape', component: MyScape },
{ path: '/account/activate', component: ActivateAccount, props: route => ({ activationToken: route.query.activationToken }) }
];

const router = createRouter({
Expand Down
18 changes: 17 additions & 1 deletion src/services/axiosService.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const login = async (email, password) => {
};






export const verifyLoginCode = async (email, code) => {
try {
const response = await axiosInstance.post('/auth/verify', { email, code });
Expand All @@ -56,6 +60,17 @@ export const verifyLoginCode = async (email, code) => {
}
};


export const ActivateAccount = async (activationToken) => {
try {
const response = await axiosInstance.get(`/auth/activate?activationToken=${activationToken}`);
return response.data;
} catch (error) {
handleApiError(error);
}
};


export const register = async (email, username, password) => {
try {
const response = await axiosInstance.post('/auth/register', { email, username, password });
Expand Down Expand Up @@ -213,5 +228,6 @@ export default {
getImageDetails,
deleteUpload,
getUser,
verifyLoginCode
verifyLoginCode,
ActivateAccount
};
43 changes: 43 additions & 0 deletions src/views/ActivateAccountView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<div>
<h1>Account Activated!</h1>
</div>
</template>

<script>
import axiosService from '@/services/axiosService';
import Cookies from 'js-cookie';
export default {
props: {
activationToken: {
type: String,
required: true
}
},
mounted() {
console.log('Activation Token:', this.activationToken);
this.processActivation(this.activationToken);
},
methods: {
async processActivation(activationToken) {
try{
const response = await axiosService.ActivateAccount(activationToken)
Cookies.set('token', response.token);
window.location.href = '/';
}catch{
console.error("error activating account and login");
window.location.href = '/';
}
}
}
}
</script>

<style scoped>
</style>

0 comments on commit 23bf785

Please sign in to comment.